Skip to content
Snippets Groups Projects
Commit edc1c9e3 authored by thijsheijden's avatar thijsheijden
Browse files

Updated keyvaluedriver and its mock

parent ec0795ab
No related branches found
No related tags found
No related merge requests found
......@@ -35,13 +35,12 @@ func (d *KeyValueDriver) Start() {
}
// Get retrieves the value from the redis store that belongs to the given key
func (d *KeyValueDriver) Get(key *string) *string {
value := d.client.Get(context.Background(), *key).Val()
return &value
func (d *KeyValueDriver) Get(key *string) string {
return d.client.Get(context.Background(), *key).Val()
}
// Set sets the key value pair in the redis store
func (d *KeyValueDriver) Set(key *string, value interface{}) error {
status := d.client.Set(context.Background(), *key, value, 0)
func (d *KeyValueDriver) Set(key *string, value *string) error {
status := d.client.Set(context.Background(), *key, *value, 0)
return status.Err()
}
......@@ -2,23 +2,23 @@ package mockkeyvaluedriver
// A KeyValueStore implements methods to set key-value data (mock)
type KeyValueStore struct {
data map[string]interface{}
data map[string]string
}
// CreateKeyValueStore creates a key value store driver (mock)
func CreateKeyValueStore() *KeyValueStore {
return &KeyValueStore{
data: make(map[string]interface{}),
data: make(map[string]string),
}
}
// Set sets a key to a value in the key value store. Expects a non-pointer as value. (mock)
func (kvs *KeyValueStore) Set(key *string, value interface{}) error {
kvs.data[*key] = value
func (kvs *KeyValueStore) Set(key *string, value *string) error {
kvs.data[*key] = *value
return nil
}
// Get gets the value for the supplied key from the key value store (mock)
func (kvs *KeyValueStore) Get(key *string) interface{} {
func (kvs *KeyValueStore) Get(key *string) string {
return kvs.data[*key]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment