cloudemu

Cache

In-memory cache with TTL support

Cache

SDK-compat status: Portable Go API only. ElastiCache / Azure Cache for Redis / Memorystore expose Redis or Memcached wire protocols, which are out of scope for HTTP-based SDK-compat. The cache management APIs may get SDK-compat handlers in a future phase. The full driver semantics (Get/Set/TTL expiry/eviction) are already available through the Portable Go API below.

Emulates cache services: ElastiCache (AWS), Cache (Azure), Memorystore (GCP).

Provider Mapping

ProviderServiceAccess
AWSElastiCacheaws.ElastiCache
AzureCache for Redisazure.Cache
GCPMemorystoregcp.Memorystore

Key Operations

Basic Operations

import cachedriver "github.com/stackshy/cloudemu/cache/driver"

// Create a cache instance
aws.ElastiCache.CreateCacheInstance(ctx, cachedriver.CacheConfig{
    Name:     "session-cache",
    NodeType: "cache.t3.micro",
})

// Set a value with TTL
aws.ElastiCache.Set(ctx, "session-cache", "user:123", []byte("session-data"), 30*time.Minute)

// Get a value
data, _ := aws.ElastiCache.Get(ctx, "session-cache", "user:123")

// Delete
aws.ElastiCache.Delete(ctx, "session-cache", "user:123")

Realistic Behaviors

  • TTL expiry: cached items are automatically expired after their TTL, with lazy cleanup on read
  • Thread-safe: all cache operations are safe for concurrent access

On this page