Documentation
¶
Index ¶
- Constants
- func Version() string
- type AdapterConfig
- type Cache
- func (this *Cache) Client() *redis.Client
- func (this *Cache) Close() error
- func (this *Cache) Decr(key string) (int64, error)
- func (this *Cache) Del(keys ...string) (int64, error)
- func (this *Cache) Delete(key string) error
- func (this *Cache) DeleteByPrefix(prefix string) error
- func (this *Cache) Exist(key string) bool
- func (this *Cache) Exists(keys ...string) (int64, error)
- func (this *Cache) Expire(key string, expiration time.Duration) (bool, error)
- func (this *Cache) Get(key string) (string, error)
- func (this *Cache) Incr(key string) (int64, error)
- func (this *Cache) Key(key string) string
- func (this *Cache) Set(key, val string, expiration time.Duration) error
- func (this *Cache) TTL(key string) (time.Duration, error)
- type Options
- type RedisCache
- func (r *RedisCache) Client() *redis.Client
- func (r *RedisCache) Close() error
- func (r *RedisCache) Decr(key string) (int64, error)
- func (r *RedisCache) Del(keys ...string) (int64, error)
- func (r *RedisCache) Delete(key string) error
- func (r *RedisCache) DeleteByPrefix(prefix string) error
- func (r *RedisCache) Exist(key string) bool
- func (r *RedisCache) Exists(keys ...string) (int64, error)
- func (r *RedisCache) Expire(key string, expiration time.Duration) (bool, error)
- func (r *RedisCache) Get(key string) (string, error)
- func (r *RedisCache) Incr(key string) (int64, error)
- func (r *RedisCache) Key(key string) string
- func (r *RedisCache) Set(key, val string, expiration time.Duration) error
- func (r *RedisCache) TTL(key string) (time.Duration, error)
- type Store
Constants ¶
View Source
const VersionName = "0.1.0"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdapterConfig ¶
type AdapterConfig struct {
Addr string
Password string
DB int
// Type of connection pool.
// true for FIFO pool, false for LIFO pool.
// Note that fifo has higher overhead compared to lifo.
PoolFIFO bool
// Maximum number of socket connections.
// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
PoolSize int
// Minimum number of idle connections which is useful when establishing
// new connection is slow.
MinIdleConns int
// redis://user:password@localhost:6789/3?dial_timeout=3&db=1&read_timeout=6s&max_retries=2
// url, 如果使用url,其他配置无效, url的优先级高于其他配置
Url string
}
AdapterConfig holds redis connection settings.
type Cache ¶
type Cache struct {
Opt Options
// contains filtered or unexported fields
}
Cache is a redis-backed cache. It wraps a Store and delegates all operations.
func (*Cache) DeleteByPrefix ¶
type Options ¶
type Options struct {
// alias
Alias string
// Adapter configuration.
AdapterConfig AdapterConfig
// key prefix Default is ""
Section string
}
Options configures a Cache instance.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache implements the Store interface backed by redis.
func NewRedisCache ¶
func NewRedisCache() *RedisCache
NewRedisCache creates and returns a new redis cache.
func (*RedisCache) Client ¶ added in v0.5.0
func (r *RedisCache) Client() *redis.Client
func (*RedisCache) Close ¶ added in v1.2.1
func (r *RedisCache) Close() error
func (*RedisCache) Delete ¶
func (r *RedisCache) Delete(key string) error
func (*RedisCache) DeleteByPrefix ¶
func (r *RedisCache) DeleteByPrefix(prefix string) error
DeleteByPrefix deletes cached values by given prefix key.
func (*RedisCache) Exist ¶ added in v1.0.6
func (r *RedisCache) Exist(key string) bool
func (*RedisCache) Exists ¶ added in v1.0.5
func (r *RedisCache) Exists(keys ...string) (int64, error)
func (*RedisCache) Key ¶ added in v0.5.2
func (r *RedisCache) Key(key string) string
type Store ¶
type Store interface {
Client() *redis.Client
Close() error
Key(key string) string
Set(key, val string, expiration time.Duration) error
Get(key string) (string, error)
Del(keys ...string) (int64, error)
Delete(key string) error
DeleteByPrefix(prefix string) error
Expire(key string, expiration time.Duration) (bool, error)
TTL(key string) (time.Duration, error)
Exists(keys ...string) (int64, error)
Exist(key string) bool
Incr(key string) (int64, error)
Decr(key string) (int64, error)
}
Store is a thin key-value cache abstraction. Redis-specific commands (hash/list/set/zset/bitmap/script) are intentionally NOT part of this interface; use Client() to access them directly.
Click to show internal directories.
Click to hide internal directories.