GCP.Redis reference
AclPolicy
Section titled “AclPolicy”Source:
src/GCP/Redis/AclPolicy.ts
A Memorystore for Redis Cluster ACL policy.
ACL policies have no labels field, so Alchemy identifies a policy by
its id: a policy found under the generated id is adopted, one found
under an explicit aclPolicyId without state is reported as unowned.
aclPolicyId and location are identity — changing either replaces
the policy. rules update in place. Create is synchronous; patch and
delete return long-running operations.
Attach the policy to a Redis Cluster with the cluster’s aclPolicy
field. A policy cannot be deleted while it is attached to a cluster.
AclPolicy: Creating an ACL Policy
Section titled “AclPolicy: Creating an ACL Policy”Generated name
const policy = yield* GCP.Redis.AclPolicy("AppAcl", { rules: [{ username: "app", rule: "on ~keys:* +get" }],});Explicit id, location, and rules
const policy = yield* GCP.Redis.AclPolicy("AppAcl", { aclPolicyId: "app-acl", location: "us-central1", rules: [ { username: "app", rule: "on ~keys:* +get" }, { username: "readonly", rule: "off ~* -@all" }, ],});AclPolicy: Updating Rules
Section titled “AclPolicy: Updating Rules”Change props on the same logical id; the engine keeps the physical id.
const policy = yield* GCP.Redis.AclPolicy("AppAcl", { location: "us-central1", rules: [{ username: "app", rule: "on ~keys:* +get +set" }],});GetAclPolicy
Section titled “GetAclPolicy”Source:
src/GCP/Redis/GetAclPolicy.ts
Runtime binding for Memorystore Redis aclPolicies.get.
Bind this operation to an AclPolicy in a Function/Action init
phase. Provide GetAclPolicyHttp.
GetAclPolicy: Observing ACL Policies
Section titled “GetAclPolicy: Observing ACL Policies”const getAclPolicy = yield* GCP.Redis.GetAclPolicy(policy);const live = yield* getAclPolicy();GetAclPolicyHttp
Section titled “GetAclPolicyHttp”Source:
src/GCP/Redis/GetAclPolicyHttp.tsKind: Layer · Provides:GCP.Redis.GetAclPolicy
HTTP implementation of GetAclPolicy.
GetAuthString
Section titled “GetAuthString”Source:
src/GCP/Redis/GetAuthString.ts
Runtime binding for Memorystore Redis instances.getAuthString.
Bind this operation to an Instance in a Function/Action init
phase. Provide GetAuthStringHttp. If AUTH is not enabled the
response authString is empty. redis.instances.getAuthString is only
in roles/redis.admin, so the host is granted that role on the project
under an IAM Condition matching the bound instance.
GetAuthString: Reading AUTH
Section titled “GetAuthString: Reading AUTH”const getAuthString = yield* GCP.Redis.GetAuthString(cache);const { authString } = yield* getAuthString();GetAuthStringHttp
Section titled “GetAuthStringHttp”Source:
src/GCP/Redis/GetAuthStringHttp.tsKind: Layer · Provides:GCP.Redis.GetAuthString
HTTP implementation of GetAuthString.
GetInstance
Section titled “GetInstance”Source:
src/GCP/Redis/GetInstance.ts
Runtime binding for Memorystore Redis instances.get.
Bind this operation to an Instance in a Function/Action init
phase. Provide GetInstanceHttp.
GetInstance: Observing Instances
Section titled “GetInstance: Observing Instances”const getInstance = yield* GCP.Redis.GetInstance(cache);const live = yield* getInstance();GetInstanceHttp
Section titled “GetInstanceHttp”Source:
src/GCP/Redis/GetInstanceHttp.tsKind: Layer · Provides:GCP.Redis.GetInstance
HTTP implementation of GetInstance.
Instance
Section titled “Instance”Source:
src/GCP/Redis/Instance.ts
A Memorystore for Redis instance.
Changing instanceId, location, tier, connectMode,
authorizedNetwork, reservedIpRange, locationId,
alternativeLocationId, transitEncryptionMode, customerManagedKey,
or readReplicasMode replaces the instance. Redis version upgrades use
instances.upgrade; a downgrade replaces the instance.
Provisioning typically takes several minutes.
Instance: Creating an Instance
Section titled “Instance: Creating an Instance”Generated name, BASIC 1 GiB
const cache = yield* GCP.Redis.Instance("Cache", {});Explicit id, labels, and AUTH
const cache = yield* GCP.Redis.Instance("Cache", { instanceId: "app-cache", location: "us-central1", memorySizeGb: 1, authEnabled: true, labels: { env: "prod" },});Instance: Binding from a Function
Section titled “Instance: Binding from a Function”export class Api extends GCP.Function<Api>()( "Api", { main: import.meta.url }, Effect.gen(function* () { const cache = yield* GCP.Redis.Instance("Cache", { memorySizeGb: 1 }); const redis = yield* GCP.Redis.ReadWriteRedis(cache); return { fetch: Effect.gen(function* () { yield* redis.set("k", "v").pipe(Effect.orDie); return HttpServerResponse.text("ok"); }), }; }).pipe(Effect.provide([GCP.Redis.ReadWriteRedisHttp])),) {}Instance: Destroying an Instance
Section titled “Instance: Destroying an Instance”const cache = yield* GCP.Redis.Instance("Cache", { memorySizeGb: 1 });alchemy destroy waits for CREATING to finish, then retries Conflict until the instance is gone.
Instance: High Availability
Section titled “Instance: High Availability”const cache = yield* GCP.Redis.Instance("Cache", { tier: "STANDARD_HA", locationId: "us-central1-a", alternativeLocationId: "us-central1-f", memorySizeGb: 1,});ReadRedis
Section titled “ReadRedis”Source:
src/GCP/Redis/ReadRedis.ts
Bind a Memorystore Instance with read access.
Uses the shared alchemy/Redis RESP client. Provide
ReadRedisHttp. The host receives only the instance endpoint; when
AUTH is enabled the runtime fetches the AUTH string with
instances.getAuthString, so the host is granted roles/redis.admin
(the only predefined role with that permission) on the project under an
IAM Condition matching this instance.
ReadRedis: Read
Section titled “ReadRedis: Read”const cache = yield* GCP.Redis.ReadRedis(Memorystore);const value = yield* cache.get("marker");ReadRedisHttp
Section titled “ReadRedisHttp”Source:
src/GCP/Redis/ReadRedisHttp.tsKind: Layer · Provides:GCP.Redis.ReadRedis
HTTP/RESP implementation of ReadRedis.
ReadWriteRedis
Section titled “ReadWriteRedis”Source:
src/GCP/Redis/ReadWriteRedis.ts
Bind a Memorystore Instance with read + write access.
Uses the shared alchemy/Redis RESP client. Provide
ReadWriteRedisHttp.
ReadWriteRedis: Read/Write
Section titled “ReadWriteRedis: Read/Write”const cache = yield* GCP.Redis.ReadWriteRedis(Memorystore);yield* cache.set("marker", "hello");const value = yield* cache.get("marker");ReadWriteRedisHttp
Section titled “ReadWriteRedisHttp”Source:
src/GCP/Redis/ReadWriteRedisHttp.tsKind: Layer · Provides:GCP.Redis.ReadWriteRedis
HTTP/RESP implementation of ReadWriteRedis.
WriteRedis
Section titled “WriteRedis”Source:
src/GCP/Redis/WriteRedis.ts
Bind a Memorystore Instance with write access.
Uses the shared alchemy/Redis RESP client. Provide
WriteRedisHttp.
WriteRedisHttp
Section titled “WriteRedisHttp”Source:
src/GCP/Redis/WriteRedisHttp.tsKind: Layer · Provides:GCP.Redis.WriteRedis
HTTP/RESP implementation of WriteRedis.