Skip to content

OCI Cache

OCI Cache clusters (Redis and Valkey), API version 20220315 (SDK package redis, client RedisClusterClient, CLI oci redis redis-cluster, Terraform oci_redis_redis_cluster). Each cluster is backed by real Valkey or Redis containers that accept TLS only, as OCI Cache does, so the endpoints GetRedisCluster returns are ones an application can connect to with any Redis client configured as in production. Real OCI serves the API on redis.{region}.oci.{domain}; floci-oci serves it on port 4599 with the other services.

Supported operations

Area Operations
Clusters CreateRedisCluster, GetRedisCluster, ListRedisClusters, UpdateRedisCluster, DeleteRedisCluster, ChangeRedisClusterCompartment
Nodes ListRedisClusterNodes
Work requests GetWorkRequest, ListWorkRequests, ListWorkRequestErrors, ListWorkRequestLogs, CancelWorkRequest

How a cluster runs

  • One container per cluster, or per shard. CreateRedisCluster returns the cluster CREATING with an IN_PROGRESS work request and starts its containers in the background: one for a NONSHARDED cluster, one per shard for a SHARDED one (see Sharded clusters). Once the cluster serves clients (the server answers PING; for a sharded cluster, every slot is assigned) it becomes ACTIVE and the work request SUCCEEDED. A container that exits, or a cluster that is not serving within FLOCI_OCI_SERVICES_REDIS_READY_TIMEOUT_SECONDS (default 60), marks the cluster FAILED and its work request FAILED, with the reason listed by ListWorkRequestErrors.
  • Software version and image. VALKEY_8_1 and VALKEY_7_2 run FLOCI_OCI_SERVICES_REDIS_VALKEY_IMAGE (default valkey/valkey:{version}-alpine, with 8.1 or 7.2); REDIS_7_0 and V7_0_5 run FLOCI_OCI_SERVICES_REDIS_REDIS_IMAGE (default redis:{version}-alpine, with 7.0 or 7.0.5). A new softwareVersion on UpdateRedisCluster restarts the servers on the new image.
  • The port. OCI Cache listens on 6379, and the RedisCluster model has no port field: clients assume 6379. Host ports come from FLOCI_OCI_SERVICES_REDIS_BASE_PORT..MAX_PORT (default 6379..6478), so the first cluster on the host sits on the port clients assume. A later cluster gets the next free port, which floci-oci logs (clients must use port ...) since it cannot travel on the wire. When floci-oci runs in a container, the endpoint is the cluster container's name on port 6379, which other containers on the shared network reach directly.
  • Endpoints. For a non-sharded cluster, primaryFqdn, replicasFqdn and every node's privateEndpointFqdn name the one container: localhost on the host, the container's name in a container. The IP fields carry the address that name resolves to from floci-oci (127.0.0.1 for localhost).
  • No replicas. nodeCount nodes are listed, but each non-sharded cluster, and each shard, is one server: the replicas endpoint is the primary.
  • No persistence. The servers keep their data in memory. A version or shard count change, a restart of floci-oci or a reset empties the cache, as a node replacement would on OCI.
  • Delete removes the containers and releases their ports, then the cluster itself: GetRedisCluster answers 404, which Terraform reads as deleted. When Docker refuses to remove a container, the delete's work request is FAILED with the Docker error, the cluster is FAILED and keeps its ports, and it can be deleted again (inferred).
  • Mock mode (FLOCI_OCI_SERVICES_REDIS_MOCK=true) starts nothing: clusters become ACTIVE at once, with endpoints in OCI's documented shape (<id>-p.redis.<region>.oci.oraclecloud.com, and <id>.redis.<region>.oci.oraclecloud.com as a sharded cluster's discovery endpoint) that nothing listens on.

TLS

OCI Cache "only supports TLS connections with clusters" by default, and a client without TLS gets connection reset by peer (Connecting to an OCI Cache Cluster). floci-oci does the same: every server listens with TLS only on 6379 (--port 0 --tls-port 6379), and there is no plain-TCP port or switch for one. The non-TLS exception OCI grants through a support request is not part of the API, so floci-oci has nothing to model it on.

  • Trust. The server certificate is issued by floci-oci's sidecar CA, which GET /_floci/sidecar-ca returns (see Emulator endpoints). With FLOCI_OCI_TLS_ENABLED=true and the generated self-signed certificate, it is the same certificate as /_floci/tls-cert. With a certificate of your own in FLOCI_OCI_TLS_CERT_PATH, floci-oci holds no CA key for it, so sidecars use a separate CA: trust the certificate from /_floci/sidecar-ca, not /_floci/tls-cert. In both cases /_floci/sidecar-ca is the one to trust.
  • Names. The certificate names localhost, 127.0.0.1, host.docker.internal, the Docker host floci-oci publishes ports on, and the name of every container of the cluster, so certificate and host name verification pass at the endpoints GetRedisCluster returns, from the host or from a container on the shared network. OCI tells clients to use the endpoint names, not IP addresses; a container's own IP is not in the certificate.
  • Client certificates are not asked for (tls-auth-clients no), as on OCI, where a client only verifies the server.
  • A new certificate is issued each time a cluster's containers start.

Sharded clusters

A SHARDED cluster runs one container per shard, each a Valkey (or Redis) cluster node with cluster-enabled yes that owns an even share of the 16384 slots. floci-oci forms the cluster as valkey-cli --cluster create would (a config epoch per node, CLUSTER ADDSLOTSRANGE, CLUSTER MEET over the shared Docker network) and marks it ACTIVE once every node reports cluster_state:ok. The cluster bus runs on TLS too (tls-cluster yes).

  • Discovery endpoint. discoveryFqdn and discoveryEndpointIpAddress name the first shard's container; primaryFqdn, replicasFqdn and their IP fields are empty, since OCI documents no cluster-level primary or replicas endpoint for a sharded cluster (the empty value is inferred). Each node in nodeCollection and ListRedisClusterNodes names its shard's container and carries its shardNumber.
  • Topology and redirects. Each node announces the host name and port a client reaches it at (cluster-announce-hostname, cluster-announce-tls-port, cluster-preferred-endpoint-type hostname), so CLUSTER SLOTS, CLUSTER SHARDS and MOVED replies name localhost:<host port> on the host, or <shard container>:6379 in a container. OCI requires a client that supports cluster mode with host names, for example valkey-cli -c, Jedis JedisCluster or Lettuce.
  • Ports. Each shard takes a host port from the same range, in shard order, so the first sharded cluster on a fresh host has its discovery endpoint on 6379 when that port is free.
  • Updates. A new shardCount restarts the cluster with that many shards, which empties it: OCI reshards in place and keeps the data (floci-oci's choice). nodeCount changes only the nodes listed.

Wire notes

  • CreateRedisCluster answers 200 with the RedisCluster, etag and opc-work-request-id. Update, delete and changeCompartment answer 202 with only opc-work-request-id.
  • Lists are wrapped collections ({"items": [...]}: RedisClusterCollection, RedisNodeCollection, WorkRequestSummaryCollection, WorkRequestErrorCollection, WorkRequestLogEntryCollection), paged with limit, page and opc-next-page. ListRedisClusters takes compartmentId, lifecycleState, displayName, id, sortBy (timeCreated, displayName) and sortOrder; compartmentId is optional, as in the SDK.
  • Work requests carry one resource with entityType redisCluster and the action Terraform matches: CREATED for a create, UPDATED for an update or a compartment move, DELETED for a delete. The operation types are CREATE_REDIS_CLUSTER, UPDATE_REDIS_CLUSTER, DELETE_REDIS_CLUSTER and MOVE_REDIS_CLUSTER. The entityType value is inferred; Terraform only needs it to contain cluster.
  • subnetId and nsgIds must exist in Networking, otherwise 400 RelatedResourceNotAuthorizedOrNotFound, and a subnet or NSG a cluster uses cannot be deleted. Missing mandatory fields answer 400 MissingParameter; an unknown softwareVersion, clusterMode or lifecycleState answers 400 InvalidParameter.
  • The cluster OCID type is rediscluster (inferred).

Emulator choices

These are floci-oci's own; no Oracle source in the reference corpus states them.

  • clusterMode defaults to NONSHARDED. A SHARDED cluster defaults to 3 shards and lists shardCount times nodeCount nodes. shardCount on a non-sharded cluster is 400 InvalidParameter.
  • nodeCount must be at least 1 and nodeMemoryInGBs greater than 0; the memory is recorded, not enforced on the container.
  • Node display names are <cluster displayName>-<n>.
  • An update, a delete or a move the cluster's state does not allow is refused with 409: IncorrectState while the cluster is CREATING, UPDATING or DELETING, which OCI SDKs retry, and Conflict otherwise. A delete cancels an operation in progress.
  • CancelWorkRequest answers 409 Conflict: operations are not cancellable.

Quickstart

# A cluster on an existing subnet (see the Networking page for creating one)
oci redis redis-cluster redis-cluster create \
  --compartment-id "$COMPARTMENT" --subnet-id "$SUBNET" \
  --display-name sessions --node-count 1 --node-memory-in-gbs 2 \
  --software-version VALKEY_8_1 --wait-for-state SUCCEEDED

# Connect with the primary endpoint, over TLS, trusting floci-oci's sidecar CA
curl -s http://localhost:4599/_floci/sidecar-ca -o floci-oci-sidecar-ca.pem
HOST=$(oci redis redis-cluster redis-cluster-summary list-redis-clusters --compartment-id "$COMPARTMENT" \
  --display-name sessions --query 'data.items[0]."primary-fqdn"' --raw-output)
valkey-cli --tls --cacert floci-oci-sidecar-ca.pem -h "$HOST" -p 6379 PING

# A sharded cluster: connect in cluster mode through the discovery endpoint
oci redis redis-cluster redis-cluster create \
  --compartment-id "$COMPARTMENT" --subnet-id "$SUBNET" \
  --display-name sessions-sharded --node-count 1 --node-memory-in-gbs 2 \
  --software-version VALKEY_8_1 --cluster-mode SHARDED --shard-count 3 --wait-for-state SUCCEEDED
DISCOVERY=$(oci redis redis-cluster redis-cluster-summary list-redis-clusters --compartment-id "$COMPARTMENT" \
  --display-name sessions-sharded --query 'data.items[0]."discovery-fqdn"' --raw-output)
valkey-cli -c --tls --cacert floci-oci-sidecar-ca.pem -h "$DISCOVERY" -p 6380 SET greeting hello

The sharded cluster above is the second cluster on the host, so its first shard sits on 6380; the port is in the floci-oci log line that reports the cluster ACTIVE.

Not emulated

IAM authentication and identity tokens, OCI Cache users and their attach and detach operations, configuration sets and default configuration sets, engine options, backups and export to Object Storage, import from Object Storage, cross-region replication (secondary clusters, switchover, convert to standalone), real replicas, resharding that keeps data, and IPv6 endpoints. Each is a follow-up in the backlog.