Documentation
¶
Index ¶
- type BadgerCache
- func (b *BadgerCache) Close()
- func (b *BadgerCache) Empty() error
- func (b *BadgerCache) EmptyByMatch(str string) error
- func (b *BadgerCache) Forget(str string) error
- func (b *BadgerCache) Get(str string) (any, error)
- func (b *BadgerCache) GetInt(key string) (int, error)
- func (b *BadgerCache) GetString(key string) (string, error)
- func (b *BadgerCache) GetTime(key string) (time.Time, error)
- func (b *BadgerCache) Has(str string) bool
- func (b *BadgerCache) Set(str string, value any, expires ...time.Duration) error
- type CacheEntry
- type CacheInterface
- type Options
- type RedisCache
- func (c *RedisCache) Close()
- func (c *RedisCache) Empty() error
- func (c *RedisCache) EmptyByMatch(match string) error
- func (c *RedisCache) Forget(key string) error
- func (c *RedisCache) Get(key string) (any, error)
- func (c *RedisCache) GetInt(key string) (int, error)
- func (c *RedisCache) GetString(key string) (string, error)
- func (c *RedisCache) GetTime(key string) (time.Time, error)
- func (c *RedisCache) Has(key string) bool
- func (c *RedisCache) Set(key string, data any, expires ...time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerCache ¶ added in v1.1.0
type BadgerCache struct { Conn *badger.DB Prefix string }
BadgerCache is the type for a Badger database cache.
func (*BadgerCache) Close ¶ added in v1.1.0
func (b *BadgerCache) Close()
Close closes the badger database.
func (*BadgerCache) Empty ¶ added in v1.1.0
func (b *BadgerCache) Empty() error
Empty removes all entries in Badger.
func (*BadgerCache) EmptyByMatch ¶ added in v1.1.0
func (b *BadgerCache) EmptyByMatch(str string) error
EmptyByMatch removes all entries in Redis which have the prefix match.
func (*BadgerCache) Forget ¶ added in v1.1.0
func (b *BadgerCache) Forget(str string) error
Forget removes an item from the cache, by key.
func (*BadgerCache) Get ¶ added in v1.1.0
func (b *BadgerCache) Get(str string) (any, error)
Get attempts to retrieve a value from the cache.
func (*BadgerCache) GetInt ¶ added in v1.1.0
func (b *BadgerCache) GetInt(key string) (int, error)
GetInt is a convenience method which retrieves a value from the cache, converts it to an int, and returns it.
func (*BadgerCache) GetString ¶ added in v1.1.0
func (b *BadgerCache) GetString(key string) (string, error)
GetString is a convenience method which retrieves a value from the cache and returns it as a string.
func (*BadgerCache) GetTime ¶ added in v1.1.0
func (b *BadgerCache) GetTime(key string) (time.Time, error)
GetTime retrieves a value from the cache by the specified key and returns it as time.Time.
func (*BadgerCache) Has ¶ added in v1.1.0
func (b *BadgerCache) Has(str string) bool
type CacheEntry ¶
type CacheEntry map[string]interface{}
CacheEntry is a map to hold values, so we can serialize them.
type CacheInterface ¶ added in v1.1.0
type CacheInterface interface { Empty() error EmptyByMatch(match string) error Forget(key string) error Get(key string) (any, error) GetInt(key string) (int, error) GetString(key string) (string, error) GetTime(key string) (time.Time, error) Has(key string) bool Set(key string, data any, expires ...time.Duration) error Close() }
CacheInterface is the interface which anything providing cache functionality must satisfy.
type Options ¶
type Options struct { Server string // The server where Redis exists. Port string // The port Redis is listening on. Password string // The password for Redis. Prefix string // A prefix to use for all keys for this client. DB int // Database. Specifying 0 (the default) means use the default database. BadgerPath string // The location for the badger database on disk. }
Options is the type used to configure a RedisCache object.
type RedisCache ¶ added in v1.1.0
type RedisCache struct { Conn *redis.Client BadgerClient *badger.DB Prefix string }
RedisCache is the type for a Redis-based cache.
func (*RedisCache) Close ¶ added in v1.1.0
func (c *RedisCache) Close()
Close closes the pool of redis connections
func (*RedisCache) Empty ¶ added in v1.1.0
func (c *RedisCache) Empty() error
Empty removes all entries in Redis for a given client.
func (*RedisCache) EmptyByMatch ¶ added in v1.1.0
func (c *RedisCache) EmptyByMatch(match string) error
EmptyByMatch removes all entries in Redis which have the prefix match.
func (*RedisCache) Forget ¶ added in v1.1.0
func (c *RedisCache) Forget(key string) error
Forget removes an item from the cache, by key.
func (*RedisCache) Get ¶ added in v1.1.0
func (c *RedisCache) Get(key string) (any, error)
Get attempts to retrieve a value from the cache.
func (*RedisCache) GetInt ¶ added in v1.1.0
func (c *RedisCache) GetInt(key string) (int, error)
GetInt is a convenience method which retrieves a value from the cache, converts it to an int, and returns it.
func (*RedisCache) GetString ¶ added in v1.1.0
func (c *RedisCache) GetString(key string) (string, error)
GetString is a convenience method which retrieves a value from the cache and returns it as a string.
func (*RedisCache) GetTime ¶ added in v1.1.0
func (c *RedisCache) GetTime(key string) (time.Time, error)
GetTime retrieves a value from the cache by the specified key and returns it as time.Time.
func (*RedisCache) Has ¶ added in v1.1.0
func (c *RedisCache) Has(key string) bool
Has checks to see if the supplied key is in the cache and returns true if found, otherwise false.