MCPcopy Index your code
hub / github.com/devaccuracy/ledgerforge / Cache

Interface Cache

internal/cache/cache.go:31–55  ·  view source on GitHub ↗

Cache interface provides the basic operations for a cache system. It includes methods for setting, getting, and deleting cached data.

Source from the content-addressed store, hash-verified

29// Cache interface provides the basic operations for a cache system.
30// It includes methods for setting, getting, and deleting cached data.
31type Cache interface {
32 // Set stores a value in the cache with a specified time-to-live (TTL).
33 // Parameters:
34 // - ctx: The context for managing the request lifecycle.
35 // - key: The cache key under which the value will be stored.
36 // - value: The value to be stored in the cache.
37 // - ttl: The duration the value should be retained in the cache.
38 // Returns an error if the operation fails.
39 Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
40
41 // Get retrieves a value from the cache using a given key.
42 // Parameters:
43 // - ctx: The context for managing the request lifecycle.
44 // - key: The cache key to fetch the value.
45 // - data: The variable to store the fetched data.
46 // Returns an error if the key does not exist or retrieval fails.
47 Get(ctx context.Context, key string, data interface{}) error
48
49 // Delete removes a value from the cache based on the provided key.
50 // Parameters:
51 // - ctx: The context for managing the request lifecycle.
52 // - key: The cache key to be deleted.
53 // Returns an error if the key cannot be deleted.
54 Delete(ctx context.Context, key string) error
55}
56
57// RedisCache implements the Cache interface, using Redis as the underlying cache store.
58// It leverages both Redis and local in-memory caching for efficient lookups.

Callers 23

TestSetFunction · 0.95
TestGetFunction · 0.95
TestDeleteFunction · 0.95
applyExternalAccountFunction · 0.65
processHTTPFunction · 0.65
TestGetFunction · 0.95
TestGetNonExistentKeyFunction · 0.95
TestDeleteFunction · 0.95

Implementers 3

mockCachedatabase/transactions_test.go
mockCacheRecondatabase/reconciliation_test.go
RedisCacheinternal/cache/cache.go

Calls

no outgoing calls

Tested by

no test coverage detected