Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigureCaching ¶
func ConfigureCaching()
ConfigureCaching is used to setup caching, if the configuration caching impl is redis, then redis will be used. If any other value is provided including empty it will be an in memory cache. Default is in memory. If using redis, implement configs for URL, Port, Username, and Password.
Types ¶
type Caching ¶
type Caching interface { CheckCache(ctx context.Context, key string) (bool, []byte) AddToCache(ctx context.Context, key string, value []byte, ttl int64) }
Caching interfaces for implementing caching, for retrieving records, and checking for existence, and adding to a cache with a TTL
var ( //Cache implementation. Injected object will have CheckCache and AddToCache available. Cache Caching )
type MemoryClient ¶
type MemoryClient struct { }
MemoryClient for implementing in memory cache.
func (*MemoryClient) AddToCache ¶
AddToCache takes in Context for tracing, key for storing in the cache, a value in the form of a byte array for storing in the cache, a TTL for how long from now the record will exist. If the key exists, the value is not nil, and the TTL is not expired then the record will be added to the cache.
func (*MemoryClient) CheckCache ¶
CheckCache method for checking if the cache has a key matching the string provided. The Context is used for tracing.
type RedisClient ¶
type RedisClient struct { }
RedisClient holds values related to connecting and using redis for caching.
func (*RedisClient) AddToCache ¶
AddToCache takes in a context for tracing, a key of the record to be stored, a []byte to be stored, and a ttl in milliseconds for how long the record should live.
func (*RedisClient) CheckCache ¶
CheckCache takes in a context for tracing and a key for searching redis. Returns whether it found the record and the []byte of the record.