{"modulePath":"github.com/MAX-API-Next/MAX-API","version":"v1.0.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cachex\n\n## Types\n\n```go\ntype HybridCache[V any] struct {\n\t// contains filtered or unexported fields\n}\n```\nHybridCache is a small helper that uses Redis when enabled, otherwise falls back to in-memory hot cache.\n\n```go\nfunc NewHybridCache[V any](cfg HybridCacheConfig[V]) *HybridCache[V]\n```\n\n```go\nfunc (c *HybridCache[V]) Algorithm() (mainCacheAlgorithm string, missingCacheAlgorithm string)\n```\n\n```go\nfunc (c *HybridCache[V]) Capacity() (mainCacheCapacity int, missingCacheCapacity int)\n```\n\n```go\nfunc (c *HybridCache[V]) DeleteByPrefix(prefix string) (int, error)\n```\n\n```go\nfunc (c *HybridCache[V]) DeleteMany(keys []string) (map[string]bool, error)\n```\nDeleteMany accepts either fully namespaced keys or raw keys and deletes them. It returns a map keyed by fully namespaced keys.\n\n```go\nfunc (c *HybridCache[V]) FullKey(key string) string\n```\n\n```go\nfunc (c *HybridCache[V]) Get(key string) (value V, found bool, err error)\n```\n\n```go\nfunc (c *HybridCache[V]) Keys() ([]string, error)\n```\nKeys returns keys with valid values. In Redis, it returns all matching keys.\n\n```go\nfunc (c *HybridCache[V]) Purge() error\n```\n\n```go\nfunc (c *HybridCache[V]) SetWithTTL(key string, v V, ttl time.Duration) error\n```\n\n```go\ntype HybridCacheConfig[V any] struct {\n\tNamespace Namespace\n\n\t// Redis is used when RedisEnabled returns true (or RedisEnabled is nil) and Redis is not nil.\n\tRedis        *redis.Client\n\tRedisCodec   ValueCodec[V]\n\tRedisEnabled func() bool\n\n\t// Memory builds a hot cache used when Redis is disabled. Keys stored in memory are fully namespaced.\n\tMemory func() *hot.HotCache[string, V]\n}\n```\n\n```go\ntype IntCodec struct{}\n```\n\n```go\nfunc (c IntCodec) Decode(s string) (int, error)\n```\n\n```go\nfunc (c IntCodec) Encode(v int) (string, error)\n```\n\n```go\ntype JSONCodec[V any] struct{}\n```\n\n```go\nfunc (c JSONCodec[V]) Decode(s string) (V, error)\n```\n\n```go\nfunc (c JSONCodec[V]) Encode(v V) (string, error)\n```\n\n```go\ntype Namespace string\n```\nNamespace isolates keys between different cache use-cases. (e.g. \"channel\\_affinity:v1\").\n\n```go\nfunc (n Namespace) FullKey(key string) string\n```\n\n```go\nfunc (n Namespace) MatchPattern() string\n```\n\n```go\ntype StringCodec struct{}\n```\n\n```go\nfunc (c StringCodec) Decode(s string) (string, error)\n```\n\n```go\nfunc (c StringCodec) Encode(v string) (string, error)\n```\n\n```go\ntype ValueCodec[V any] interface {\n\tEncode(v V) (string, error)\n\tDecode(s string) (V, error)\n}\n```\n\n","path":"github.com/MAX-API-Next/MAX-API/pkg/cachex","name":"cachex","synopsis":"","isRedistributable":true}
