package storage import ( "src.dualinventive.com/go/lib/kv" ) // KV is a key-value storage that satisfy the simulator storage type KV struct { deviceUID string storage kv.KV } // NewKV create a dinet/kv storage bound onto DeviceUID func NewKV(deviceUID, KVType, KVParam string) (*KV, error) { kvstorage, err := kv.New(KVType, KVParam) if err != nil { return nil, err } return &KV{deviceUID: deviceUID, storage: kvstorage}, nil } // Set a value for key func (k *KV) Set(key string, value interface{}) error { return k.storage.HSet(k.deviceUID, key, value) } // Get a value for key func (k *KV) Get(key string) (interface{}, error) { return k.storage.HGet(k.deviceUID, key) } // Del a key/value func (k *KV) Del(key string) error { return k.storage.HDel(k.deviceUID, key) }