Documentation ¶
Index ¶
- Constants
- func GetOrFetch(c Cache, key string, fx func() (interface{}, time.Duration, error), ...) (interface{}, error)
- type Cache
- type MemoryCache
- func (c *MemoryCache) Delete(keys ...string) error
- func (c *MemoryCache) DeleteExpired()
- func (c *MemoryCache) Flush()
- func (c *MemoryCache) Get(key string) (interface{}, bool, error)
- func (c *MemoryCache) GetExpiration(key string) (time.Time, error)
- func (c *MemoryCache) GetOrFetch(key string, fx func() (interface{}, time.Duration, error), ...) (interface{}, error)
- func (c *MemoryCache) Items() map[string]interface{}
- func (c *MemoryCache) Set(key string, value interface{}, expiration time.Duration) error
- func (c *MemoryCache) SetDefault(key string, value interface{}) error
- func (c *MemoryCache) Size() int
- type MemoryCacheItem
- type RedisCache
- func (c *RedisCache) Delete(keys ...string) error
- func (c *RedisCache) Flush()
- func (c *RedisCache) Get(key string) (interface{}, bool, error)
- func (c *RedisCache) GetExpiration(key string) (time.Time, error)
- func (c *RedisCache) GetOrFetch(key string, fx func() (interface{}, time.Duration, error), ...) (interface{}, error)
- func (c *RedisCache) Set(key string, value interface{}, expiration time.Duration) error
- func (c *RedisCache) SetDefault(key string, value interface{}) error
- func (c *RedisCache) Size() int
Constants ¶
View Source
const DefaultExpiration time.Duration = 0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶ added in v0.0.5
type Cache interface { Set(key string, value interface{}, expiration time.Duration) error SetDefault(key string, value interface{}) error Get(key string) (interface{}, bool, error) GetExpiration(key string) (time.Time, error) GetOrFetch(key string, fx func() (interface{}, time.Duration, error), fv func(v interface{}) (interface{}, error)) (interface{}, error) Delete(keys ...string) error Size() int Flush() }
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
func NewMemoryCache ¶
func NewMemoryCache(defaultExpiration time.Duration, items map[string]MemoryCacheItem) *MemoryCache
func NewMemoryCacheWithCleaner ¶
func NewMemoryCacheWithCleaner(defaultExpiration, cleanInterval time.Duration, items map[string]MemoryCacheItem) *MemoryCache
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(keys ...string) error
func (*MemoryCache) DeleteExpired ¶
func (c *MemoryCache) DeleteExpired()
func (*MemoryCache) Flush ¶
func (c *MemoryCache) Flush()
func (*MemoryCache) GetExpiration ¶
func (c *MemoryCache) GetExpiration(key string) (time.Time, error)
func (*MemoryCache) GetOrFetch ¶ added in v0.0.9
func (*MemoryCache) Items ¶
func (c *MemoryCache) Items() map[string]interface{}
func (*MemoryCache) Set ¶
func (c *MemoryCache) Set(key string, value interface{}, expiration time.Duration) error
func (*MemoryCache) SetDefault ¶
func (c *MemoryCache) SetDefault(key string, value interface{}) error
func (*MemoryCache) Size ¶
func (c *MemoryCache) Size() int
type MemoryCacheItem ¶
type MemoryCacheItem struct { Object interface{} Expiration int64 }
func (MemoryCacheItem) Expired ¶
func (item MemoryCacheItem) Expired() bool
type RedisCache ¶ added in v0.0.5
type RedisCache struct {
// contains filtered or unexported fields
}
func NewRedisCache ¶ added in v0.0.5
func NewRedisCache(defaultExpiration time.Duration, cli *rdx.Client) *RedisCache
func (*RedisCache) Delete ¶ added in v0.0.5
func (c *RedisCache) Delete(keys ...string) error
func (*RedisCache) Flush ¶ added in v0.0.5
func (c *RedisCache) Flush()
func (*RedisCache) Get ¶ added in v0.0.5
func (c *RedisCache) Get(key string) (interface{}, bool, error)
func (*RedisCache) GetExpiration ¶ added in v0.0.5
func (c *RedisCache) GetExpiration(key string) (time.Time, error)
func (*RedisCache) GetOrFetch ¶ added in v0.0.9
func (*RedisCache) Set ¶ added in v0.0.5
func (c *RedisCache) Set(key string, value interface{}, expiration time.Duration) error
func (*RedisCache) SetDefault ¶ added in v0.0.5
func (c *RedisCache) SetDefault(key string, value interface{}) error
func (*RedisCache) Size ¶ added in v0.0.5
func (c *RedisCache) Size() int
Click to show internal directories.
Click to hide internal directories.