Documentation
¶
Overview ¶
Package cache is a cache dependency management on-top of the famous redigo package
Index ¶
- func Connect(url string, ...) error
- func ConnectToURL(urlString string) (c redis.Conn, err error)
- func Delete(keys ...string) (total int, err error)
- func DestroyCache() (err error)
- func DidRegisterKillByDependencyScript() bool
- func Disconnect()
- func Exists(key string) (bool, error)
- func Expire(key string, duration time.Duration) (err error)
- func Get(key string) (string, error)
- func GetAllKeys() (keys []string, err error)
- func GetBytes(key string) ([]byte, error)
- func GetConnection() redis.Conn
- func GetOrSetWithExpirationGob(key string, fn GobCacheCreator, duration time.Duration, dependencies ...string) (data []byte, err error)
- func GetPool() *redis.Pool
- func GetStringSlice(key string) (destination []string, err error)
- func HashGet(hash, key string) (string, error)
- func HashMapGet(hashName string, keys ...interface{}) ([]string, error)
- func HashMapSet(hashName string, pairs [][2]interface{}, dependencies ...string) (err error)
- func HashMapSetExp(hashName string, pairs [][2]interface{}, ttl time.Duration, ...) (err error)
- func HashSet(hashName, hashKey string, value interface{}, dependencies ...string) (err error)
- func KillByDependency(keys ...string) (total int, err error)
- func RegisterScript(script string) (sha string, err error)
- func RegisterScripts() (err error)
- func Set(key string, value interface{}, dependencies ...string) (err error)
- func SetAdd(setName, member interface{}, dependencies ...string) (err error)
- func SetExp(key string, value interface{}, ttl time.Duration, dependencies ...string) (err error)
- func SetIsMember(set, member interface{}) (bool, error)
- func SetRemoveMember(set, member interface{}) (err error)
- type GobCacheCreator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
func Connect(url string, maxActiveConnections, idleConnections, maxConnLifetime, idleTimeout int) error
Connect creates a new connection pool connected to the specified url
func ConnectToURL ¶
ConnectToURL connects via REDIS_URL Source: github.com/soveran/redisurl URL Format: redis://localhost:6379
func DestroyCache ¶
func DestroyCache() (err error)
DestroyCache will flush the entire redis server. It only removes keys, not scripts
func DidRegisterKillByDependencyScript ¶
func DidRegisterKillByDependencyScript() bool
DidRegisterKillByDependencyScript returns true if the script has a sha from redis
func GetAllKeys ¶
GetAllKeys returns a []string of keys
func GetConnection ¶
GetConnection will return a connection from the pool. The connection must be closed when done with use to return it to the pool
func GetOrSetWithExpirationGob ¶
func GetOrSetWithExpirationGob(key string, fn GobCacheCreator, duration time.Duration, dependencies ...string) (data []byte, err error)
GetOrSetWithExpirationGob will return the cached value for the key or use the GobCacheCreator to create and insert the value into the cache. If the expiration time is set to a value greater than zero, the key will be set to expire in the provided duration
func GetStringSlice ¶
GetStringSlice returns a []string stored in redis
func HashMapGet ¶
HashMapGet gets values from a hash map for corresponding keys
func HashMapSet ¶
HashMapSet will set the hashKey to the value in the specified hashName and link a reference to each dependency for the entire hash
func HashMapSetExp ¶
func HashMapSetExp(hashName string, pairs [][2]interface{}, ttl time.Duration, dependencies ...string) (err error)
HashMapSetExp will set the hashKey to the value in the specified hashName and link a reference to each dependency for the entire hash
func HashSet ¶
HashSet will set the hashKey to the value in the specified hashName and link a reference to each dependency for the entire hash
func KillByDependency ¶
KillByDependency removes all keys which are listed as depending on the key(s) Also: Delete()
func RegisterScript ¶
RegisterScript register a script
func Set ¶
Set will set the key in redis and keep a reference to each dependency value can be both a string or []byte
func SetAdd ¶
SetAdd will add the member to the Set and link a reference to each dependency for the entire Set
func SetExp ¶
SetExp will set the key in redis and keep a reference to each dependency value can be both a string or []byte
func SetIsMember ¶
SetIsMember returns if the member is part of the set
func SetRemoveMember ¶
func SetRemoveMember(set, member interface{}) (err error)
SetRemoveMember removes the member from the set
Types ¶
type GobCacheCreator ¶
GobCacheCreator can be used to generate the content to store. If the content is not found, the creator will be invoked and the result will be stored and returned