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.