storage

package
v0.0.0-...-106977a Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2021 License: Apache-2.0 Imports: 18 Imported by: 9

Documentation

Index

Constants

View Source
const NumberOfColumns = 10
View Source
const TruncateInterval = 60 * 1000

Variables

View Source
var LastTruncate = int64(0)
View Source
var MY_SQL_STORAGE = "mysql"
View Source
var POSTGRE_SQL_STORAGE = "postgresql"
View Source
var REDIS_STORAGE = "redis"
View Source
var SQLITE_STORAGE = "sqlite"

Functions

func CalculateHash

func CalculateHash(data string) uint32

func CalculateHashesOfColumns

func CalculateHashesOfColumns(columns []string) []uint32

func CheckTableName

func CheckTableName(table string) error

func CreateWhereClause

func CreateWhereClause(columns []string, hashes []uint32) string

func SplitToParts

func SplitToParts(key string) []string

Types

type GenericStorage

type GenericStorage struct {
	Credentials map[string]string
	StorageType string
}

func (*GenericStorage) AddToMap

func (gs *GenericStorage) AddToMap(table string, key string, objectKey string, object interface{}) error

func (*GenericStorage) DelFromMap

func (gs *GenericStorage) DelFromMap(table string, key string, objectKey string) error

func (*GenericStorage) DelKey

func (gs *GenericStorage) DelKey(table string, key string) (int64, error)

func (*GenericStorage) GetFromMap

func (gs *GenericStorage) GetFromMap(table string, key string, objectKey string, reference interface{}) error

func (*GenericStorage) GetFullKey

func (gs *GenericStorage) GetFullKey(key string) (string, error)

func (*GenericStorage) GetKey

func (gs *GenericStorage) GetKey(table string, key string) (string, error)

func (*GenericStorage) GetKeys

func (gs *GenericStorage) GetKeys(table string, pattern string) ([]string, error)

func (*GenericStorage) GetMap

func (gs *GenericStorage) GetMap(table string, key string, reference interface{}) error

func (*GenericStorage) Init

func (gs *GenericStorage) Init() error

func (*GenericStorage) SetKey

func (gs *GenericStorage) SetKey(table string, key string, value string, expiration time.Duration) error

type MySQLStorage

type MySQLStorage struct {
	Connection *sql.DB
}

func (*MySQLStorage) AddToMap

func (mss *MySQLStorage) AddToMap(table string, key string, objectKey string, object string) error

func (*MySQLStorage) Create

func (mss *MySQLStorage) Create(credentials map[string]string) error

func (*MySQLStorage) DelFromMap

func (mss *MySQLStorage) DelFromMap(table string, key string, objectKey string) error

func (*MySQLStorage) DelKey

func (mss *MySQLStorage) DelKey(table string, key string) (int64, error)

func (*MySQLStorage) Destroy

func (mss *MySQLStorage) Destroy() error

func (*MySQLStorage) GetFromMap

func (mss *MySQLStorage) GetFromMap(table string, key string, objectKey string) (string, error)

func (*MySQLStorage) GetFullKey

func (mss *MySQLStorage) GetFullKey(key string) (string, error)

func (*MySQLStorage) GetKey

func (mss *MySQLStorage) GetKey(table string, key string) (string, error)

func (*MySQLStorage) GetKeys

func (mss *MySQLStorage) GetKeys(table string, pattern string) ([]string, error)

func (*MySQLStorage) GetMap

func (mss *MySQLStorage) GetMap(table string, key string) (map[string]string, error)

func (*MySQLStorage) Init

func (mss *MySQLStorage) Init() error

func (*MySQLStorage) KeysCleanUp

func (mss *MySQLStorage) KeysCleanUp() error

func (*MySQLStorage) SetKey

func (mss *MySQLStorage) SetKey(table string, key string, value string, expiration time.Duration) error

func (*MySQLStorage) Setup

func (mss *MySQLStorage) Setup(credentials map[string]string) error

type PostgreSQLStorage

type PostgreSQLStorage struct {
	Connection *sql.DB
}

func (*PostgreSQLStorage) AddToMap

func (pss *PostgreSQLStorage) AddToMap(table string, key string, objectKey string, object string) error

func (*PostgreSQLStorage) Create

func (pss *PostgreSQLStorage) Create(credentials map[string]string) error

func (*PostgreSQLStorage) DelFromMap

func (pss *PostgreSQLStorage) DelFromMap(table string, key string, objectKey string) error

func (*PostgreSQLStorage) DelKey

func (pss *PostgreSQLStorage) DelKey(table string, key string) (int64, error)

func (*PostgreSQLStorage) Destroy

func (pss *PostgreSQLStorage) Destroy() error

func (*PostgreSQLStorage) GetFromMap

func (pss *PostgreSQLStorage) GetFromMap(table string, key string, objectKey string) (string, error)

func (*PostgreSQLStorage) GetFullKey

func (pss *PostgreSQLStorage) GetFullKey(key string) (string, error)

func (*PostgreSQLStorage) GetKey

func (pss *PostgreSQLStorage) GetKey(table string, key string) (string, error)

func (*PostgreSQLStorage) GetKeys

func (pss *PostgreSQLStorage) GetKeys(table string, pattern string) ([]string, error)

func (*PostgreSQLStorage) GetMap

func (pss *PostgreSQLStorage) GetMap(table string, key string) (map[string]string, error)

func (*PostgreSQLStorage) Init

func (pss *PostgreSQLStorage) Init() error

func (*PostgreSQLStorage) KeysCleanUp

func (pss *PostgreSQLStorage) KeysCleanUp() error

func (*PostgreSQLStorage) SetKey

func (pss *PostgreSQLStorage) SetKey(table string, key string, value string, expiration time.Duration) error

func (*PostgreSQLStorage) Setup

func (pss *PostgreSQLStorage) Setup(credentials map[string]string) error

type RedisStorage

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

func (*RedisStorage) AddToMap

func (rs *RedisStorage) AddToMap(table string, key string, objectKey string, object string) error

func (*RedisStorage) Create

func (rs *RedisStorage) Create(credentials map[string]string) error

func (*RedisStorage) DelFromMap

func (rs *RedisStorage) DelFromMap(table string, key string, objectKey string) error

func (*RedisStorage) DelKey

func (rs *RedisStorage) DelKey(table string, key string) (int64, error)

func (*RedisStorage) Destroy

func (rs *RedisStorage) Destroy() error

func (*RedisStorage) GetFromMap

func (rs *RedisStorage) GetFromMap(table string, key string, objectKey string) (string, error)

func (*RedisStorage) GetFullKey

func (rs *RedisStorage) GetFullKey(key string) (string, error)

func (*RedisStorage) GetKey

func (rs *RedisStorage) GetKey(table string, key string) (string, error)

func (*RedisStorage) GetKeys

func (rs *RedisStorage) GetKeys(table string, pattern string) ([]string, error)

func (*RedisStorage) GetMap

func (rs *RedisStorage) GetMap(table string, key string) (map[string]string, error)

func (*RedisStorage) Init

func (rs *RedisStorage) Init() error

func (*RedisStorage) SetKey

func (rs *RedisStorage) SetKey(table string, key string, value string, expiration time.Duration) error

func (*RedisStorage) Setup

func (rs *RedisStorage) Setup(credentials map[string]string) error

type SQLiteStorage

type SQLiteStorage struct {
	Connection *sql.DB
}

func (*SQLiteStorage) AddToMap

func (ss *SQLiteStorage) AddToMap(table string, key string, objectKey string, object string) error

func (*SQLiteStorage) Create

func (ss *SQLiteStorage) Create(credentials map[string]string) error

func (*SQLiteStorage) DelFromMap

func (ss *SQLiteStorage) DelFromMap(table string, key string, objectKey string) error

func (*SQLiteStorage) DelKey

func (ss *SQLiteStorage) DelKey(table string, key string) (int64, error)

func (*SQLiteStorage) Destroy

func (ss *SQLiteStorage) Destroy() error

func (*SQLiteStorage) GetFromMap

func (ss *SQLiteStorage) GetFromMap(table string, key string, objectKey string) (string, error)

func (*SQLiteStorage) GetFullKey

func (ss *SQLiteStorage) GetFullKey(key string) (string, error)

func (*SQLiteStorage) GetKey

func (ss *SQLiteStorage) GetKey(table string, key string) (string, error)

func (*SQLiteStorage) GetKeys

func (ss *SQLiteStorage) GetKeys(table string, pattern string) ([]string, error)

func (*SQLiteStorage) GetMap

func (ss *SQLiteStorage) GetMap(table string, key string) (map[string]string, error)

func (*SQLiteStorage) Init

func (ss *SQLiteStorage) Init() error

func (*SQLiteStorage) KeysCleanUp

func (ss *SQLiteStorage) KeysCleanUp() error

func (*SQLiteStorage) SetKey

func (ss *SQLiteStorage) SetKey(table string, key string, value string, expiration time.Duration) error

func (*SQLiteStorage) Setup

func (ss *SQLiteStorage) Setup(credentials map[string]string) error

type Storage

type Storage interface {
	Setup(credentials map[string]string) error
	Init() error
	Create(credentials map[string]string) error
	Destroy() error
	GetKeys(table string, pattern string) ([]string, error)
	SetKey(table string, key string, value string, expiration time.Duration) error
	GetFullKey(key string) (string, error)
	GetKey(table string, key string) (string, error)
	DelKey(table string, key string) (int64, error)
	AddToMap(table string, key string, objectKey string, object string) error
	DelFromMap(table string, key string, objectKey string) error
	GetFromMap(table string, key string, objectKey string) (string, error)
	GetMap(table string, key string) (map[string]string, error)
}

func CreateStorage

func CreateStorage(credentials map[string]string, storageType string, setup bool) (Storage, error)

Jump to

Keyboard shortcuts

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