Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("cache: key not found")
Functions ¶
func GetJSON ¶ added in v1.1.40
GetJSON tries to get a value from the Cache and unmarshals it into the provided type.
Types ¶
type Cache ¶
type Cache interface {
// Get returns the value associated with the provided key, if any, and a boolean value representing if a value was associated with the key.
Get(key string) (string, bool, error)
// Put stores a value and associates it to a key for X seconds after which it expires.
// If the duration is 0, the value never expires.
Put(key string, value string, duration time.Duration) error
// Forget removes the key-value pair.
Forget(key string) error
// Increment increments the value of a key by 1.
Increment(key string) (int64, error)
// Expire sets the expiration time for a key.
Expire(key string, duration time.Duration) error
// IncrementWithInitialExpiry increments the value of a key by 1 and set the expiration time for the key if it does not have one.
IncrementWithInitialExpiry(key string, duration time.Duration) (int64, error)
// ForgetAll removes all key-value that match the given pattern
ForgetAll(keyPattern string) (int, error)
// Keys get all keys match given pattern
Keys(keyPattern string) ([]string, error)
}
Click to show internal directories.
Click to hide internal directories.