Documentation ¶
Index ¶
- func Get(c Connection, key string, data interface{}) error
- func GetAll(c Connection, keys []string, kind interface{}) (map[string]interface{}, error)
- func ScanKeys(c Connection, key string) ([]string, error)
- func Set(c Connection, key string, data interface{}) error
- func SetWithTTL(c Connection, key string, data interface{}, ttl time.Duration) error
- type Connection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(c Connection, key string, data interface{}) error
Get will load and unmarshal a database entry for the provided key into the provided object. If the entry isn't present in the database then no error will be returned. If the entry can't be can't be properly unmarshalled then a json error will be returned.
func GetAll ¶
func GetAll(c Connection, keys []string, kind interface{}) (map[string]interface{}, error)
GetAll will load and unmarshal multiple database entries for the provided slice of keys and return the values in a map indexed by key. If a particular key is not found then the value of kind, will be used in its place. For each key that is found, a new instance of the same type as kind will be created and the json value will be unmarshalled into it. If a value can't be properly unmarshalled then a json error will be returned.
func ScanKeys ¶
func ScanKeys(c Connection, key string) ([]string, error)
ScanKeys will scan the database for keys that match the provided key (with wildcards). Each matching key will be returned or an error returned if the database couldn't be scanned for some reason.
func Set ¶
func Set(c Connection, key string, data interface{}) error
Set will write the provided entry to the database for the provided key. If the entry can't be marshalled to JSON or is unable to be written to the database for some reason then an error will be returned.
func SetWithTTL ¶
func SetWithTTL(c Connection, key string, data interface{}, ttl time.Duration) error
SetWithTTL will write the provided entry to the database for the provided key with a TTL. Once the TTL's time elapses the key will be automatically deleted from the database. If the entry can't be marshalled to JSON or is unable to be written to the database for some reason then an error will be returned.
Types ¶
type Connection ¶
A connection that can perform operations against a database.