Cacher is an interface on top of different databases
go get github.com/csturiale/cacher
opts := cache.Options{
Server: localhost,
Port: 6379,
Password: "",
Prefix: "myprefix",
DB: 0
}
db, err = cache.New(&cache.RedisCache{}, &opts)
if err != nil {
log.Fatalf("Cannot connect to redis")
}opts := cache.Options{
Path: "badger"
}
db, err = cache.New(&cache.BadgerCache{}, &opts)
if err != nil {
log.Fatalf("Cannot connect to Badger")
}opts := cache.Options{
Path: ":memory:" // For in memory DB, otherwise you can set a path
}
db, err = cache.New(&cache.BuntDBCache{}, &opts)
if err != nil {
log.Fatalf("Cannot connect to BuntDB")
}