storages

Collection of key-value storages adapters for Golang

This project is maintained by reddec

Redis

API docs

Wrapper around Redis hashmap where one storage is one hashmap.

Each namespace is each key supposing that the value is hashmap.

Closing root (parent) storage will close all namespaced storages but not vice-versa.

URL initialization

Do not forget to import package!

redis://[[user][:<password>]@]<host>[:port][/<dbnum>][?key=<key>]

Where:

Example:

Usage

With new connection

storage, err := New("my-space", "redis://redishost")
if err != nil {
   panic(err)    
}
defer storage.Close()

or with helper that will panic on error

storage := MustNew("my-space", "redis://redishost")
defer storage.Close()

Wrap connection

storage := NewClient("my-space", redisConnection)
defer storage.Close()

Features

Namespaces

Support NamespacedStorage interface.

It allows make nested sub-storages with independent key space.

Example:

aliceStorage := storage.Namespace([]byte("alice"))
bobStorage := storage.Namespace([]byte("bob"))