mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 16:18:44 +05:00
29 lines
491 B
Go
29 lines
491 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"github.com/simonz05/godis"
|
|
)
|
|
|
|
type RedisStorage struct {
|
|
db *godis.Client
|
|
}
|
|
|
|
func NewRedisStorage(address string) (*RedisStorage, error) {
|
|
ndb:= godis.New(address, 10, "")
|
|
log.Print("Starting redis storage")
|
|
return &RedisStorage{db: ndb}, nil
|
|
}
|
|
|
|
|
|
func (rs *RedisStorage) Close() {
|
|
log.Print("Closing redis storage")
|
|
rs.db.Quit()
|
|
}
|
|
|
|
func (rs *RedisStorage) Get(key string) (string, error) {
|
|
elem, err := rs.db.Get(key)
|
|
return elem.String(), err
|
|
}
|
|
|