Different implementations of storages with same abstract interface:
// Thread-safe storage for key-value
type Storage interface {
// Put single item to storage. If already exists - override
Put(key []byte, data []byte) error
// Get item from storage. If not exists - os.ErrNotExist (implementation independent)
Get(key []byte) ([]byte, error)
// Delete key and value
Del(key []byte) error
// Iterate over all keys. Modification during iteration may cause undefined behaviour (mostly - dead-lock)
Keys(handler func(key []byte) error) error
// Close storage if needs
io.Closer
}
See documentation for details
one more example...
You can create different storage types just by URL (if you imported required package):
For example, use Redis db as a backend
storage, err := std.Create("redis://localhost")
if err != nil {
panic(err)
}
defer storage.Close()
Look to releases section
Add public Bintray key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
- supported distribution: trusty, xenial, bionic, buster, wheezy
echo "deb https://dl.bintray.com/reddec/debian {distribution} main" | sudo tee -a /etc/apt/sources.list
Ubuntu 18.04 (bionic)
echo "deb https://dl.bintray.com/reddec/debian bionic main" | sudo tee -a /etc/apt/sources.list
Ubuntu 16.04 (xenial)
echo "deb https://dl.bintray.com/reddec/debian xenial main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install storages
- requires Go 1.13+
go get github.com/reddec/storages/cmd/...
The wrappers itself licensed under MIT but used libraries may have different license politics.