Documentation ¶
Index ¶
- func ToKey(in interface{}) string
- type HashKeyValueRepo
- func (repo *HashKeyValueRepo) Contains(key string) bool
- func (repo *HashKeyValueRepo) ContainsValue(in interface{}) bool
- func (repo *HashKeyValueRepo) Count() (int, error)
- func (repo *HashKeyValueRepo) Delete(key string) error
- func (repo *HashKeyValueRepo) Find(key string) (KeyValuePair, error)
- func (repo *HashKeyValueRepo) FindAll() ([]KeyValuePair, error)
- func (repo *HashKeyValueRepo) Overwrite(in interface{}) (KeyValuePair, error)
- func (repo *HashKeyValueRepo) Save(in interface{}) (KeyValuePair, error)
- type InMemoryRepo
- func (repo *InMemoryRepo) Delete(key string) error
- func (repo *InMemoryRepo) Find(key string) (KeyValuePair, error)
- func (repo *InMemoryRepo) FindAll() ([]KeyValuePair, error)
- func (repo *InMemoryRepo) Overwrite(key string, in interface{}) (KeyValuePair, error)
- func (repo *InMemoryRepo) Save(key string, in interface{}) (KeyValuePair, error)
- type KeyValuePair
- type KeyValueRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HashKeyValueRepo ¶
type HashKeyValueRepo struct {
// contains filtered or unexported fields
}
HashKeyValueRepo extends functionalities of KeyValueStore. Implementations are based on methods provided in the inner repository. The performance is not optimal since it is not based upon a native persistence layer, but instead on an additional layer of abstraction.
func NewHashKeyValueRepo ¶
func NewHashKeyValueRepo(repo KeyValueRepo) *HashKeyValueRepo
NewHashKeyValueRepo creates a new instance and uses an initialized KeyValueRepo
func (*HashKeyValueRepo) Contains ¶
func (repo *HashKeyValueRepo) Contains(key string) bool
Contains checks if a given key is in the repository
func (*HashKeyValueRepo) ContainsValue ¶
func (repo *HashKeyValueRepo) ContainsValue(in interface{}) bool
ContainsValue checks if a value is in the repository
func (*HashKeyValueRepo) Count ¶
func (repo *HashKeyValueRepo) Count() (int, error)
Count calls FindAll() and calculates the length
func (*HashKeyValueRepo) Delete ¶
func (repo *HashKeyValueRepo) Delete(key string) error
Delete calls function of wrapped repository
func (*HashKeyValueRepo) Find ¶
func (repo *HashKeyValueRepo) Find(key string) (KeyValuePair, error)
Find calls function of wrapped repository
func (*HashKeyValueRepo) FindAll ¶
func (repo *HashKeyValueRepo) FindAll() ([]KeyValuePair, error)
FindAll calls function of wrapped repository
func (*HashKeyValueRepo) Overwrite ¶
func (repo *HashKeyValueRepo) Overwrite(in interface{}) (KeyValuePair, error)
Overwrite calls function of wrapped repository
func (*HashKeyValueRepo) Save ¶
func (repo *HashKeyValueRepo) Save(in interface{}) (KeyValuePair, error)
Save calls function of wrapped repository
type InMemoryRepo ¶
type InMemoryRepo struct {
// contains filtered or unexported fields
}
InMemoryRepo stores all entities in-memory
func NewInMemoryRepo ¶
func NewInMemoryRepo() *InMemoryRepo
NewInMemoryRepo creates a new instance of the repository
func (*InMemoryRepo) Delete ¶
func (repo *InMemoryRepo) Delete(key string) error
Delete an item from the repository
func (*InMemoryRepo) Find ¶
func (repo *InMemoryRepo) Find(key string) (KeyValuePair, error)
Find retrieves and item from the repository
func (*InMemoryRepo) FindAll ¶
func (repo *InMemoryRepo) FindAll() ([]KeyValuePair, error)
FindAll items
func (*InMemoryRepo) Overwrite ¶
func (repo *InMemoryRepo) Overwrite(key string, in interface{}) (KeyValuePair, error)
func (*InMemoryRepo) Save ¶
func (repo *InMemoryRepo) Save(key string, in interface{}) (KeyValuePair, error)
Save one item
type KeyValuePair ¶
type KeyValuePair struct { Key string `json:"key"` Value interface{} `json:"value"` }
KeyValuePair has the stored entity in addition to an autogenerated id
func (KeyValuePair) ToStruct ¶
func (item KeyValuePair) ToStruct(jsonString string) (interface{}, error)
ToStruct converts json string to struct
type KeyValueRepo ¶
type KeyValueRepo interface { FindAll() ([]KeyValuePair, error) // saves an item, if the key of the item already exists an error is returned Save(key string, in interface{}) (KeyValuePair, error) // saves an item, if the key of the item already exists it is overwritten Overwrite(key string, in interface{}) (KeyValuePair, error) Delete(key string) error Find(key string) (KeyValuePair, error) }
KeyValueRepo is a generic repository which accepts values of type interface