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.
CreateRedisClusterreturns the clusterCREATINGwith anIN_PROGRESSwork request and starts its containers in the background: one for aNONSHARDEDcluster, one per shard for aSHARDEDone (see Sharded clusters). Once the cluster serves clients (the server answersPING; for a sharded cluster, every slot is assigned) it becomesACTIVEand the work requestSUCCEEDED. A container that exits, or a cluster that is not serving withinFLOCI_OCI_SERVICES_REDIS_READY_TIMEOUT_SECONDS(default 60), marks the clusterFAILEDand its work requestFAILED, with the reason listed byListWorkRequestErrors. - Software version and image.
VALKEY_8_1andVALKEY_7_2runFLOCI_OCI_SERVICES_REDIS_VALKEY_IMAGE(defaultvalkey/valkey:{version}-alpine, with8.1or7.2);REDIS_7_0andV7_0_5runFLOCI_OCI_SERVICES_REDIS_REDIS_IMAGE(defaultredis:{version}-alpine, with7.0or7.0.5). A newsoftwareVersiononUpdateRedisClusterrestarts 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(default6379..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,replicasFqdnand every node'sprivateEndpointFqdnname the one container:localhoston 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.1forlocalhost). - No replicas.
nodeCountnodes 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:
GetRedisClusteranswers404, which Terraform reads as deleted. When Docker refuses to remove a container, the delete's work request isFAILEDwith the Docker error, the cluster isFAILEDand keeps its ports, and it can be deleted again (inferred). - Mock mode (
FLOCI_OCI_SERVICES_REDIS_MOCK=true) starts nothing: clusters becomeACTIVEat once, with endpoints in OCI's documented shape (<id>-p.redis.<region>.oci.oraclecloud.com, and<id>.redis.<region>.oci.oraclecloud.comas 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-careturns (see Emulator endpoints). WithFLOCI_OCI_TLS_ENABLED=trueand the generated self-signed certificate, it is the same certificate as/_floci/tls-cert. With a certificate of your own inFLOCI_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-cais 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 endpointsGetRedisClusterreturns, 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.
discoveryFqdnanddiscoveryEndpointIpAddressname the first shard's container;primaryFqdn,replicasFqdnand 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 innodeCollectionandListRedisClusterNodesnames its shard's container and carries itsshardNumber. - 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), soCLUSTER SLOTS,CLUSTER SHARDSandMOVEDreplies namelocalhost:<host port>on the host, or<shard container>:6379in a container. OCI requires a client that supports cluster mode with host names, for examplevalkey-cli -c, JedisJedisClusteror 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
shardCountrestarts the cluster with that many shards, which empties it: OCI reshards in place and keeps the data (floci-oci's choice).nodeCountchanges only the nodes listed.
Wire notes
CreateRedisClusteranswers200with the RedisCluster,etagandopc-work-request-id. Update, delete and changeCompartment answer202with onlyopc-work-request-id.- Lists are wrapped collections (
{"items": [...]}:RedisClusterCollection,RedisNodeCollection,WorkRequestSummaryCollection,WorkRequestErrorCollection,WorkRequestLogEntryCollection), paged withlimit,pageandopc-next-page.ListRedisClusterstakescompartmentId,lifecycleState,displayName,id,sortBy(timeCreated,displayName) andsortOrder;compartmentIdis optional, as in the SDK. - Work requests carry one resource with
entityTyperedisClusterand the action Terraform matches:CREATEDfor a create,UPDATEDfor an update or a compartment move,DELETEDfor a delete. The operation types areCREATE_REDIS_CLUSTER,UPDATE_REDIS_CLUSTER,DELETE_REDIS_CLUSTERandMOVE_REDIS_CLUSTER. TheentityTypevalue is inferred; Terraform only needs it to containcluster. subnetIdandnsgIdsmust exist in Networking, otherwise400 RelatedResourceNotAuthorizedOrNotFound, and a subnet or NSG a cluster uses cannot be deleted. Missing mandatory fields answer400 MissingParameter; an unknownsoftwareVersion,clusterModeorlifecycleStateanswers400 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.
clusterModedefaults toNONSHARDED. ASHARDEDcluster defaults to 3 shards and listsshardCounttimesnodeCountnodes.shardCounton a non-sharded cluster is400 InvalidParameter.nodeCountmust be at least 1 andnodeMemoryInGBsgreater 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:IncorrectStatewhile the cluster isCREATING,UPDATINGorDELETING, which OCI SDKs retry, andConflictotherwise. A delete cancels an operation in progress. CancelWorkRequestanswers409 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.