LocalCloud Memorystore (Redis/Valkey) Local Emulator
Get started
local.cloud / agents
Read this page as Markdown ↗
local.cloud — Memorystore (Redis/Valkey) Local Emulator .md Open tab

Memorystore (Redis/Valkey)

Memorystore provides managed in-memory data services on Google Cloud. LocalCloud uses a Valkey runtime for documented Redis-compatible commands and instance metadata.

When to use Memorystore (Redis/Valkey)

Typical uses

Use when frequently accessed values, expiring entries, counters, or streams fit Redis commands and an in-memory access model. Choose key names and expiries around the application's cache or queue behavior.

Examples

  • Application caches and counters
  • Redis-compatible queues and streams

Explore another service

View all

Example usage

Service ID: memorystore. Starts by default. Use an already running LocalCloud runtime for the examples below.

Export the local project and mapped endpoints in your client process, then use the client settings below. First-time setup

# Export GOOGLE_CLOUD_PROJECT and REDIS_HOST
eval "$(localcloud env)"

REST gateway examples use the generated HTTP address in SERVICE_USAGE_EMULATOR_HOST; native SDKs can use a different protocol.

redis-cli

Set and read a cache value

Set and retrieve a short-lived key; Memorystore speeds up repeated reads through a Redis-compatible cache.

Use a native Redis client against the generated Valkey endpoint.

Configure redis-cli

: "${REDIS_HOST:?Export the LocalCloud environment first}"
export REDISCLI_HOST="${REDIS_HOST%:*}"
export REDISCLI_PORT="${REDIS_HOST##*:}"

Run in your terminal

KEY="example-$(date +%s)-$$"
redis-cli -h "$REDISCLI_HOST" -p "$REDISCLI_PORT" SET "$KEY" "Hello from LocalCloud!" EX 60
redis-cli -h "$REDISCLI_HOST" -p "$REDISCLI_PORT" GET "$KEY"
redis-cli -h "$REDISCLI_HOST" -p "$REDISCLI_PORT" DEL "$KEY"

Verify the result

SET returns OK, GET returns Hello from LocalCloud!, and DEL removes the temporary key. The key also expires after 60 seconds.

Verify a resource workflow by creating isolated state, performing the operation, and reading the result back. Run cleanup even after a failure; delete only test-owned resources.

Connection failed? Check localcloud status --verbose, enabled services, and client exports. Stop accidental Google Cloud calls; correct local routing before retrying.

Documented workflows

  • Valkey RESP, Lua, Pub/Sub, streams, and transactions

    Connect a Redis-compatible client to the Valkey endpoint, write a key, and verify expiry or transaction behavior. Use separate channel names when testing Pub/Sub across application namespaces.

  • Redis instance lifecycle, configuration, version labels, and AUTH retrieval

    Create an instance resource, update configuration or version labels, and retrieve its AUTH string. Check the shared data plane separately from administration metadata.

Service boundaries

  • Shared server; database numbers do not isolate Pub/Sub channels
  • No multi-shard topology, managed failover, or project authorization
Agent testing

Use Memorystore (Redis/Valkey) with an AI agent

Before the agent changes application logic, have it create local Memorystore (Redis/Valkey) state, read it back with the project SDK, and note which feature the check covered. That first local call catches accidental production routing and needs no GCP account, service-account key, or billing project.

Configure this repo

Set up this repository to use LocalCloud for local GCP development. First read https://local.cloud/ai/agents.md, then inspect this repo, identify the GCP services and SDK language, configure emulator environment variables, and run the narrowest integration test against localhost. Do not use real GCP credentials or production endpoints.

Production endpoints, auth, IAM, quotas, regional behavior, and final release validation still need the target Google Cloud project.

Agent resources has more prompts and the AGENTS.md template.

Related guides

Desktop view