Skip to content

GCP.Redis reference

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.

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" },
],
});

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" }],
});

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.

const getAclPolicy = yield* GCP.Redis.GetAclPolicy(policy);
const live = yield* getAclPolicy();

Source: src/GCP/Redis/GetAclPolicyHttp.ts Kind: Layer · Provides: GCP.Redis.GetAclPolicy

HTTP implementation of GetAclPolicy.

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.

const getAuthString = yield* GCP.Redis.GetAuthString(cache);
const { authString } = yield* getAuthString();

Source: src/GCP/Redis/GetAuthStringHttp.ts Kind: Layer · Provides: GCP.Redis.GetAuthString

HTTP implementation of GetAuthString.

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.

const getInstance = yield* GCP.Redis.GetInstance(cache);
const live = yield* getInstance();

Source: src/GCP/Redis/GetInstanceHttp.ts Kind: Layer · Provides: GCP.Redis.GetInstance

HTTP implementation of GetInstance.

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.

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" },
});
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])),
) {}
const cache = yield* GCP.Redis.Instance("Cache", { memorySizeGb: 1 });

alchemy destroy waits for CREATING to finish, then retries Conflict until the instance is gone.

const cache = yield* GCP.Redis.Instance("Cache", {
tier: "STANDARD_HA",
locationId: "us-central1-a",
alternativeLocationId: "us-central1-f",
memorySizeGb: 1,
});

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.

const cache = yield* GCP.Redis.ReadRedis(Memorystore);
const value = yield* cache.get("marker");

Source: src/GCP/Redis/ReadRedisHttp.ts Kind: Layer · Provides: GCP.Redis.ReadRedis

HTTP/RESP implementation of ReadRedis.

Source: src/GCP/Redis/ReadWriteRedis.ts

Bind a Memorystore Instance with read + write access.

Uses the shared alchemy/Redis RESP client. Provide ReadWriteRedisHttp.

const cache = yield* GCP.Redis.ReadWriteRedis(Memorystore);
yield* cache.set("marker", "hello");
const value = yield* cache.get("marker");

Source: src/GCP/Redis/ReadWriteRedisHttp.ts Kind: Layer · Provides: GCP.Redis.ReadWriteRedis

HTTP/RESP implementation of ReadWriteRedis.

Source: src/GCP/Redis/WriteRedis.ts

Bind a Memorystore Instance with write access.

Uses the shared alchemy/Redis RESP client. Provide WriteRedisHttp.

Source: src/GCP/Redis/WriteRedisHttp.ts Kind: Layer · Provides: GCP.Redis.WriteRedis

HTTP/RESP implementation of WriteRedis.