object_store

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deserializer

type Deserializer func(serialized string) (interface{}, error)

Deserializer turns a string into an object

type ObjectMap

type ObjectMap interface {
	Set(key string, object interface{}) error
	Delete(key string) error
	Get(key string) (interface{}, error)
	GetAll() (map[string]interface{}, error)
	DeleteAll() error
}

ObjectMap is an interface for getting objects from an arbitrary data store

type RedisClient

type RedisClient interface {
	HSet(hash string, field string, value string) error
	HGet(hash string, field string) (string, error)
	HGetAll(hash string) (map[string]string, error)
	HDel(hash string, field string) error
}

RedisClient defines an interface to interact with Redis. Only hash functions are used for now

func NewRedisClient

func NewRedisClient() (RedisClient, error)

NewRedisClient gets the redis configuration from the service config and returns a new client or an error if something went wrong

type RedisClientImpl

type RedisClientImpl struct {
	RawClient *redis.Client
}

RedisClientImpl is the implementation of the redis client using an actual connection to redis using go-redis

func (*RedisClientImpl) HDel

func (client *RedisClientImpl) HDel(hash string, field string) error

HDel deletes a value at a hash,field pair

func (*RedisClientImpl) HGet

func (client *RedisClientImpl) HGet(hash string, field string) (string, error)

HGet gets a value at a hash,field pair

func (*RedisClientImpl) HGetAll

func (client *RedisClientImpl) HGetAll(hash string) (map[string]string, error)

HGetAll gets all the possible values for fields in a hash

func (*RedisClientImpl) HSet

func (client *RedisClientImpl) HSet(hash string, field string, value string) error

HSet sets a value at a hash,field pair

type RedisMap

type RedisMap struct {
	// contains filtered or unexported fields
}

RedisMap is an ObjectMap that stores objects in Redis using hash functions

func NewRedisMap

func NewRedisMap(
	client RedisClient,
	hash string,
	serializer Serializer,
	deserializer Deserializer,
) *RedisMap

NewRedisMap creates a new redis map

func (*RedisMap) Delete

func (rm *RedisMap) Delete(key string) error

func (*RedisMap) DeleteAll

func (rm *RedisMap) DeleteAll() error

func (*RedisMap) Get

func (rm *RedisMap) Get(key string) (interface{}, error)

Get retrieves an object from the map

func (*RedisMap) GetAll

func (rm *RedisMap) GetAll() (map[string]interface{}, error)

GetAll returns all objects in the map

func (*RedisMap) Set

func (rm *RedisMap) Set(key string, object interface{}) error

Set sets an object in the map

type Serializer

type Serializer func(object interface{}) (string, error)

Serializer turns an object into a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL