storage

package
v2.10.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const VersionKey = "_version"

VersionKey indicates the data (schema) version

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangedFielder

type ChangedFielder interface {
	ChangedFields() []string
}

ChangedFielder interface is used to see what fields to update

type ListOptions

type ListOptions struct {
	Limit  uint64
	Offset uint64
	// contains filtered or unexported fields
}

ListOptions are options for all list commands

func (ListOptions) GetTotalAndSelected added in v2.3.0

func (o ListOptions) GetTotalAndSelected() (total, selected uint64)

GetTotalAndSelected returns the total number of items, along with the number of selected items

func (*ListOptions) UseCache added in v2.10.0

func (o *ListOptions) UseCache(key string, ttl time.Duration)

UseCache instructs the list operation to use a result cache.

type MigrateFunction added in v2.5.0

type MigrateFunction func(client *redis.Client, key string, input map[string]string) (nextVersion string, output map[string]string, err error)

MigrateFunction migrates data from its old version to the latest

type RedisKVStore

type RedisKVStore struct {
	*RedisStore
}

RedisKVStore stores arbitrary data in Redis

func NewRedisKVStore

func NewRedisKVStore(client *redis.Client, prefix string) *RedisKVStore

NewRedisKVStore creates a new RedisKVStore

func (*RedisKVStore) Create

func (s *RedisKVStore) Create(key string, value string) error

Create a new record, prepending the prefix to the key if necessary This function returns an error if the record already exists

func (*RedisKVStore) Get

func (s *RedisKVStore) Get(key string) (string, error)

Get one result, prepending the prefix to the key if necessary

func (*RedisKVStore) GetAll

func (s *RedisKVStore) GetAll(keys []string, options *ListOptions) (map[string]string, error)

GetAll returns all results for the given keys, prepending the prefix to the keys if necessary

func (*RedisKVStore) List

func (s *RedisKVStore) List(selector string, options *ListOptions) (map[string]string, error)

List all results matching the selector, prepending the prefix to the selector if necessary

func (*RedisKVStore) Set added in v2.5.4

func (s *RedisKVStore) Set(key string, value string) error

Set a record, prepending the prefix to the key if necessary

func (*RedisKVStore) Update

func (s *RedisKVStore) Update(key string, value string) error

Update an existing record, prepending the prefix to the key if necessary This function returns an error if the record does not exist

type RedisMapStore

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

RedisMapStore stores structs as HMaps in Redis

func NewRedisMapStore

func NewRedisMapStore(client *redis.Client, prefix string) *RedisMapStore

NewRedisMapStore returns a new RedisMapStore that talks to the given Redis client and respects the given prefix

func (*RedisMapStore) AddMigration added in v2.5.0

func (s *RedisMapStore) AddMigration(version string, migrate MigrateFunction)

AddMigration adds a data migration for a version

func (*RedisMapStore) Create

func (s *RedisMapStore) Create(key string, value interface{}, properties ...string) error

Create a new record, prepending the prefix to the key if necessary, optionally setting only the given properties This function returns an error if the record already exists

func (*RedisMapStore) Get

func (s *RedisMapStore) Get(key string) (interface{}, error)

Get one result, prepending the prefix to the key if necessary This function will migrate outdated results to newer versions if migrations are set

func (*RedisMapStore) GetAll

func (s *RedisMapStore) GetAll(keys []string, options *ListOptions) ([]interface{}, error)

GetAll returns all results for the given keys, prepending the prefix to the keys if necessary This function will migrate outdated results to newer versions if migrations are set

func (*RedisMapStore) GetFields

func (s *RedisMapStore) GetFields(key string, fields ...string) (interface{}, error)

GetFields for a record, prepending the prefix to the key if necessary This function does *not* migrate outdated results to newer versions

func (*RedisMapStore) List

func (s *RedisMapStore) List(selector string, options *ListOptions) ([]interface{}, error)

List all results matching the selector, prepending the prefix to the selector if necessary

func (*RedisMapStore) Migrate added in v2.5.0

func (s *RedisMapStore) Migrate(selector string) error

Migrate all documents matching the selector

func (*RedisMapStore) Set added in v2.5.4

func (s *RedisMapStore) Set(key string, value interface{}, properties ...string) error

Set a record, prepending the prefix to the key if necessary, optionally setting only the given properties

func (*RedisMapStore) SetBase

func (s *RedisMapStore) SetBase(base interface{}, tagName string)

SetBase sets the base struct for automatically encoding and decoding to and from Redis format

func (*RedisMapStore) SetDecoder

func (s *RedisMapStore) SetDecoder(decoder func(input map[string]string) (output interface{}, err error))

SetDecoder sets the decoder to convert structs from Redis format

func (*RedisMapStore) SetEncoder

func (s *RedisMapStore) SetEncoder(encoder func(input interface{}, properties ...string) (map[string]string, error))

SetEncoder sets the encoder to convert structs to Redis format

func (*RedisMapStore) Update

func (s *RedisMapStore) Update(key string, value interface{}, properties ...string) error

Update an existing record, prepending the prefix to the key if necessary, optionally setting only the given properties This function returns an error if the record does not exist

type RedisQueueStore added in v2.5.0

type RedisQueueStore struct {
	*RedisStore
}

RedisQueueStore stores queues in Redis

func NewRedisQueueStore added in v2.5.0

func NewRedisQueueStore(client *redis.Client, prefix string) *RedisQueueStore

NewRedisQueueStore creates a new RedisQueueStore

func (*RedisQueueStore) AddEnd added in v2.5.0

func (s *RedisQueueStore) AddEnd(key string, values ...string) error

AddEnd adds one or more values to the end of the queue, prepending the prefix to the key if necessary If you add AddEnd("value1", "value2") to an empty queue, then the Next(key) will return "value1".

func (*RedisQueueStore) AddFront added in v2.5.0

func (s *RedisQueueStore) AddFront(key string, values ...string) error

AddFront adds one or more values to the front of the queue, prepending the prefix to the key if necessary If you add AddFront("value1", "value2") to an empty queue, then the Next(key) will return "value2".

func (*RedisQueueStore) Get added in v2.5.0

func (s *RedisQueueStore) Get(key string) (res []string, err error)

Get one result, prepending the prefix to the key if necessary The items remain in the queue after the Get operation

func (*RedisQueueStore) GetAll added in v2.5.0

func (s *RedisQueueStore) GetAll(keys []string, options *ListOptions) (map[string][]string, error)

GetAll returns all results for the given keys, prepending the prefix to the keys if necessary

func (*RedisQueueStore) GetEnd added in v2.5.0

func (s *RedisQueueStore) GetEnd(key string, length int) (res []string, err error)

GetEnd gets <length> items from the end of the queue, prepending the prefix to the key if necessary The items remain in the queue after the Get operation

func (*RedisQueueStore) GetFront added in v2.5.0

func (s *RedisQueueStore) GetFront(key string, length int) (res []string, err error)

GetFront gets <length> items from the front of the queue, prepending the prefix to the key if necessary The items remain in the queue after the Get operation

func (*RedisQueueStore) Length added in v2.5.0

func (s *RedisQueueStore) Length(key string) (int, error)

Length gets the size of a queue, prepending the prefix to the key if necessary

func (*RedisQueueStore) List added in v2.5.0

func (s *RedisQueueStore) List(selector string, options *ListOptions) (map[string][]string, error)

List all results matching the selector, prepending the prefix to the selector if necessary

func (*RedisQueueStore) Next added in v2.5.0

func (s *RedisQueueStore) Next(key string) (string, error)

Next removes the first element from the queue and returns it, prepending the prefix to the key if necessary

func (*RedisQueueStore) Trim added in v2.5.0

func (s *RedisQueueStore) Trim(key string, length int) error

Trim the length of the queue

type RedisSetStore

type RedisSetStore struct {
	*RedisStore
}

RedisSetStore stores sets in Redis

func NewRedisSetStore

func NewRedisSetStore(client *redis.Client, prefix string) *RedisSetStore

NewRedisSetStore creates a new RedisSetStore

func (*RedisSetStore) Add

func (s *RedisSetStore) Add(key string, values ...string) error

Add one or more values to the set, prepending the prefix to the key if necessary

func (*RedisSetStore) Contains

func (s *RedisSetStore) Contains(key string, value string) (res bool, err error)

Contains returns wheter the set contains a given value, prepending the prefix to the key if necessary

func (*RedisSetStore) Count added in v2.6.1

func (s *RedisSetStore) Count(key string) (int, error)

Count the number of items for the given key

func (*RedisSetStore) Get

func (s *RedisSetStore) Get(key string) (res []string, err error)

Get one result, prepending the prefix to the key if necessary

func (*RedisSetStore) GetAll

func (s *RedisSetStore) GetAll(keys []string, options *ListOptions) (map[string][]string, error)

GetAll returns all results for the given keys, prepending the prefix to the keys if necessary

func (*RedisSetStore) List

func (s *RedisSetStore) List(selector string, options *ListOptions) (map[string][]string, error)

List all results matching the selector, prepending the prefix to the selector if necessary

func (*RedisSetStore) Remove

func (s *RedisSetStore) Remove(key string, values ...string) error

Remove one or more values from the set, prepending the prefix to the key if necessary

type RedisStore added in v2.5.4

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

RedisStore is the base of more specialized stores

func NewRedisStore added in v2.5.4

func NewRedisStore(client *redis.Client, prefix string) *RedisStore

NewRedisStore creates a new RedisStore

func (*RedisStore) Count added in v2.5.4

func (s *RedisStore) Count(selector string, options *ListOptions) (int, error)

Count the results matching the selector

func (*RedisStore) Delete added in v2.5.4

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

Delete an existing record, prepending the prefix to the key if necessary

func (*RedisStore) Keys added in v2.5.4

func (s *RedisStore) Keys(selector string, opts *ListOptions) ([]string, error)

Keys matching the selector, prepending the prefix to the selector if necessary

type Time

type Time struct {
	time.Time
}

Time is a wrapper around time.Time that marshals and unmarshals to the time.RFC3339Nano format

func (Time) MarshalText

func (t Time) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(in []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface

Jump to

Keyboard shortcuts

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