datastore

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

README

kvdatastore

Purpose

KVDatastore or Key-Value Datastore is a data storage abstraction that is used to abstract the data source used to back the kv-like map. Its meant to simplify the use of a simple data structure that is backed with a variety of datasources.

Supported Datastores
  • Memory only(basically a map, useful for testing)
  • Afero-backed filessystem
    • Memory
    • OS
    • Union
    • SFTP
    • Anything Afero supports
  • Redis

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataStore

type DataStore interface {
	Get(key string) (string, bool)
	Set(key string, value string) error
	Delete(key string) error
	Keys() ([]string, error)
	Values() ([]string, error)
}

DataStore interface, main interface for all datastores

type FileStore

type FileStore struct {
	SaveOnChange bool
	// contains filtered or unexported fields
}

func NewFileStore

func NewFileStore(storage afero.Fs, filename string, saveOnChange bool) (*FileStore, error)

func (*FileStore) Close

func (fs *FileStore) Close() error

func (*FileStore) Delete

func (fs *FileStore) Delete(key string) error

func (*FileStore) Get

func (fs *FileStore) Get(key string) (string, bool)

func (*FileStore) Keys

func (fs *FileStore) Keys() ([]string, error)

func (*FileStore) Set

func (fs *FileStore) Set(key string, value string) error

func (*FileStore) Sync

func (fs *FileStore) Sync() error

func (*FileStore) Values

func (fs *FileStore) Values() ([]string, error)

type MemoryDataStore

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

MemoryDataStore Memory based datastore

func NewMemoryDataStore

func NewMemoryDataStore() MemoryDataStore

func (*MemoryDataStore) Delete

func (m *MemoryDataStore) Delete(key string) error

func (*MemoryDataStore) Get

func (m *MemoryDataStore) Get(key string) (string, bool)

func (*MemoryDataStore) Keys

func (m *MemoryDataStore) Keys() ([]string, error)

func (*MemoryDataStore) Set

func (m *MemoryDataStore) Set(key string, value string) error

func (*MemoryDataStore) Values

func (m *MemoryDataStore) Values() ([]string, error)

type PersistentDataStore

type PersistentDataStore interface {
	DataStore
	io.Closer
	Sync() error
}

PersistentDataStore flushes to some storage medium

type RedisStore

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

RedisStore Redis Backed datastore

func NewRedisStore

func NewRedisStore(pool *redis.Pool, prefix string) (*RedisStore, error)

func (*RedisStore) Delete

func (r *RedisStore) Delete(key string) error

func (*RedisStore) Get

func (r *RedisStore) Get(key string) (string, bool)

func (*RedisStore) IsValidConnection

func (r *RedisStore) IsValidConnection() (bool, error)

func (*RedisStore) Keys

func (r *RedisStore) Keys() ([]string, error)

func (*RedisStore) Set

func (r *RedisStore) Set(key string, value string) error

func (*RedisStore) Values

func (r *RedisStore) Values() ([]string, error)

Directories

Path Synopsis
io

Jump to

Keyboard shortcuts

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