Documentation ¶
Index ¶
- type CacheCandidate
- type RedisConfig
- type RedisSession
- func (s *RedisSession) DelByPattern(pattern string) (int64, error)
- func (s *RedisSession) DelKey(key string) (int64, error)
- func (s *RedisSession) DelKeys(keys ...string) (int64, error)
- func (s *RedisSession) Get(key string) (string, error)
- func (s *RedisSession) GetKeys(pattern string) ([]string, error)
- func (s *RedisSession) GetScan(parentid1, parentid2 string, dest interface{}, basetype CacheCandidate) error
- func (s *RedisSession) GetScanByKey(key string, dest interface{}) error
- func (s *RedisSession) ListCandidates() map[string]string
- func (s *RedisSession) Raw() *redis.Client
- func (s *RedisSession) RegisterCandidate(cd CacheCandidate, description string)
- func (s *RedisSession) Set(value CacheCandidate, parentid1, parentid2 string) error
- func (s *RedisSession) SetSlice(value interface{}, parentid1, parentid2 string, basetype CacheCandidate) error
- func (s *RedisSession) SetSliceWithExp(value interface{}, parentid1, parentid2 string, expiration time.Duration, ...) error
- func (s *RedisSession) SetStr(value, key string, expiration time.Duration) error
- func (s *RedisSession) SetWithExp(value CacheCandidate, expiration time.Duration, parentid1, parentid2 string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheCandidate ¶
type CacheCandidate interface { //GetKey will give actual formatted key to be used to cache data GetKey(parentid1, parentid2 string) string //GetMasterKey return only patten of key - for display purpose only GetMasterKey() string //GetExpiration will give Expiration duration GetExpiration() time.Duration }
CacheCandidate defines base to create structs that can be added to cache
type RedisConfig ¶
type RedisConfig struct { //RedisServerHost is name of machine to connect for Redis Cache Host string //RedisServerPort is port of machine to connect for Redis Cache Port int DB int // from 0 to 16 Pwd string KeyPrefix string ExpirationInMinute int //Debug if set to true, will print debug messages at console. Debug bool }
RedisConfig is only used cache LabST items
type RedisSession ¶
type RedisSession struct { CacheExpiration time.Duration // contains filtered or unexported fields }
RedisSession defines connection to specific redis server an exposes methods to save/retrive data.
func InitSession ¶
func InitSession(config RedisConfig) *RedisSession
InitSession initialize session with redis server with given config
func (*RedisSession) DelByPattern ¶
func (s *RedisSession) DelByPattern(pattern string) (int64, error)
DelByPattern - first fils keys begins with given pattern then delete them
func (*RedisSession) DelKey ¶
func (s *RedisSession) DelKey(key string) (int64, error)
DelKey delete single given key
func (*RedisSession) DelKeys ¶
func (s *RedisSession) DelKeys(keys ...string) (int64, error)
DelKeys - delete multiple keys as geven []string
func (*RedisSession) Get ¶
func (s *RedisSession) Get(key string) (string, error)
Get return value of given key from cache
func (*RedisSession) GetKeys ¶
func (s *RedisSession) GetKeys(pattern string) ([]string, error)
GetKeys find and return keys beginning with given pattern
func (*RedisSession) GetScan ¶
func (s *RedisSession) GetScan(parentid1, parentid2 string, dest interface{}, basetype CacheCandidate) error
GetScan retrive value from cache then deserialize to given dest type
func (*RedisSession) GetScanByKey ¶
func (s *RedisSession) GetScanByKey(key string, dest interface{}) error
GetScanByKey retrive value from cache then deserialize to given dest type
func (*RedisSession) ListCandidates ¶
func (s *RedisSession) ListCandidates() map[string]string
ListCandidates list all registered candidates
func (*RedisSession) Raw ¶ added in v1.0.1
func (s *RedisSession) Raw() *redis.Client
Raw allow to execute all commands on redis without any pre-check, use with responsibility
func (*RedisSession) RegisterCandidate ¶
func (s *RedisSession) RegisterCandidate(cd CacheCandidate, description string)
RegisterCandidate - register cachecandidate to list
func (*RedisSession) Set ¶
func (s *RedisSession) Set(value CacheCandidate, parentid1, parentid2 string) error
Set either add new record or update existing with default expiration set in CacheCandidate
func (*RedisSession) SetSlice ¶
func (s *RedisSession) SetSlice(value interface{}, parentid1, parentid2 string, basetype CacheCandidate) error
SetSlice set []struct to cache with default expiration set in CacheCandidate
func (*RedisSession) SetSliceWithExp ¶
func (s *RedisSession) SetSliceWithExp(value interface{}, parentid1, parentid2 string, expiration time.Duration, basetype CacheCandidate) error
SetSliceWithExp set []struct to cache with given expiration
func (*RedisSession) SetStr ¶
func (s *RedisSession) SetStr(value, key string, expiration time.Duration) error
SetStr sets raw string with given key and expiration
func (*RedisSession) SetWithExp ¶
func (s *RedisSession) SetWithExp(value CacheCandidate, expiration time.Duration, parentid1, parentid2 string) error
SetWithExp set struct to cache with custom expiration