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 // in case of RESP2ClusterProxy protocol, it is the address of the proxy 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, the default logger will print nothing Logger logger.Logger // ClusterNodes is a list of cluster nodes // only being used by ProtoResp2ClusterProxy protocol. // We currently need to list all of the slave IPs // TODO: make it auto detect cluster nodes ClusterNodes []string }
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)
const ( // ProtoResp2 represent RESP2 protocol that is used from Redis 2 ProtoResp2 Protocol = "RESP2" // ProtoResp2ClusterProxy represent RESP2 protocol on redis cluster // with front proxy ProtoResp2ClusterProxy Protocol = "RESP2ClusterProxy" // ProtoResp3 represents RESP3 protocol that supported since Redis 6 ProtoResp3 Protocol = "RESP3" )
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