Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// redis server address
ServerAddr string
// size of the in memory cache
// Default is 10K
CacheSize int
// Protocol of redis being used.
//
// The default is ProtoResp2
Protocol Protocol
// logger to be used, use default logger which print to stderr on error
Logger logger.Logger
}
Config represents config of Cache
type Protocol ¶
type Protocol string
Protocol represents the underlying Redis protocol used by rimcu. It currently support RESP2 & RESP3 (experimental)
type Rimcu ¶
type Rimcu struct {
// contains filtered or unexported fields
}
Rimcu is a redis client which implements client side caching. It is safe for concurrent use by multiples goroutine
func (*Rimcu) NewStringsCache ¶
func (r *Rimcu) NewStringsCache(cfg StringsCacheConfig) (*StringsCache, error)
NewStringsCache creates a new strings cache and do the required initialization
type StringsCache ¶
type StringsCache struct {
// contains filtered or unexported fields
}
StringsCache is Rimcu client for the strings redis data type
func (*StringsCache) Del ¶
func (sc *StringsCache) Del(ctx context.Context, key string) error
Del deletes the key in both memory cache and redis server
func (*StringsCache) Get ¶
func (sc *StringsCache) Get(ctx context.Context, key string, expSecond int) (result.StringsResult, error)
Get gets the value of key.
It gets from the redis server only if the value not exists in memory cache, it then put the value from server in the in memcache with the given expiration
type StringsCacheConfig ¶
type StringsCacheConfig struct {
CacheSize int
CacheTTLSec int
// contains filtered or unexported fields
}
StringsCacheConfig is the configuration of the StringsCache