keyvaluestore: github.com/ccbrown/keyvaluestore Index | Files | Directories

package keyvaluestore

import "github.com/ccbrown/keyvaluestore"

Index

Package Files

atomic_write_operation.go backend.go batch_operation.go keyvaluestore.go

Constants

const MaxAtomicWriteOperations = 25

DynamoDB can't do more than 25 operations in an atomic write so all backends should enforce this limit.

func ToString Uses

func ToString(v interface{}) *string

type AtomicWriteOperation Uses

type AtomicWriteOperation interface {
    // Sets a key. No conditionals are applied.
    Set(key string, value interface{}) AtomicWriteResult

    // Sets a key. The atomic write operation will be aborted if the key already exists.
    SetNX(key string, value interface{}) AtomicWriteResult

    // Sets a key. The atomic write operation will be aborted if the key does not exist or does not
    // have the given value.
    SetEQ(key string, value, oldValue interface{}) AtomicWriteResult

    // Deletes a key. No conditionals are applied.
    Delete(key string) AtomicWriteResult

    // Increments the given key by some number. If the key doesn't exist, it's set to the given
    // number instead. No conditionals are applied.
    IncrBy(key string, n int64) AtomicWriteResult

    // Adds a member to a sorted set. No conditionals are applied.
    ZAdd(key string, member interface{}, score float64) AtomicWriteResult

    // Removes a member from a sorted set. No conditionals are applied.
    ZRem(key string, member interface{}) AtomicWriteResult

    // Adds a member to a set. No conditionals are applied.
    SAdd(key string, member interface{}, members ...interface{}) AtomicWriteResult

    // Removes a member from a set. No conditionals are applied.
    SRem(key string, member interface{}, members ...interface{}) AtomicWriteResult

    // Executes the operation. If a condition failed, returns false.
    Exec() (bool, error)
}

type AtomicWriteResult Uses

type AtomicWriteResult interface {
    // Returns true if the transaction failed due to this operation's conditional failing.
    ConditionalFailed() bool
}

type Backend Uses

type Backend interface {
    // Batch allows you to batch up simple operations for better performance potential. Use this
    // only for possible performance benefits. Read isolation is implementation-defined and other
    // properties such as atomicity should not be assumed.
    Batch() BatchOperation

    // AtomicWrite executes up to 25 write operations atomically, failing entirely if any
    // conditional operations (e.g. SetNX) are not executed.
    AtomicWrite() AtomicWriteOperation

    Delete(key string) (success bool, err error)
    Get(key string) (*string, error)
    Set(key string, value interface{}) error

    // Increments the given key by some number. If the key doesn't exist, it's set to the given
    // number instead.
    IncrBy(key string, n int64) (int64, error)

    // Set if the key already exists.
    SetXX(key string, value interface{}) (bool, error)

    // Set if the key doesn't exist.
    SetNX(key string, value interface{}) (bool, error)

    // Set if the key exists and its value is equal to the given one.
    SetEQ(key string, value, oldValue interface{}) (success bool, err error)

    // Add to or create a set. Sets are ideal for small sizes, but have implementation-dependent
    // size limitations (400KB for DynamoDB). For large or unbounded sets, use ZAdd instead.
    SAdd(key string, member interface{}, members ...interface{}) error

    // Remove from a set.
    SRem(key string, member interface{}, members ...interface{}) error

    // Get members of a set.
    SMembers(key string) ([]string, error)

    // Add to or create a sorted set.
    ZAdd(key string, member interface{}, score float64) error

    // Gets the score for a member added via ZAdd.
    ZScore(key string, member interface{}) (*float64, error)

    // Remove from a sorted set.
    ZRem(key string, member interface{}) error

    // Increment a score in a sorted set or set the score if the member doesn't exist.
    ZIncrBy(key string, member string, n float64) (float64, error)

    // Get members of a sorted set by ascending score.
    ZRangeByScore(key string, min, max float64, limit int) ([]string, error)

    // Get members (and their scores) of a sorted set by ascending score.
    ZRangeByScoreWithScores(key string, min, max float64, limit int) (ScoredMembers, error)

    // Get members of a sorted set by descending score.
    ZRevRangeByScore(key string, min, max float64, limit int) ([]string, error)

    // Get members (and their scores) of a sorted set by descending score.
    ZRevRangeByScoreWithScores(key string, min, max float64, limit int) (ScoredMembers, error)

    // Gets the number of members with scores between min and max, inclusive.
    ZCount(key string, min, max float64) (int, error)

    // Gets the number of members between min and max. All members of the set must have been added
    // with a zero score. min and max must begin with '(' or '[' to indicate exclusive or inclusive.
    // Alternatively, min can be "-" and max can be "+" to represent infinities.
    ZLexCount(key string, min, max string) (int, error)

    // Get members of a sorted set by lexicographical order. All members of the set must have been
    // added with a zero score. min and max must begin with '(' or '[' to indicate exclusive or
    // inclusive. Alternatively, min can be "-" and max can be "+" to represent infinities.
    ZRangeByLex(key string, min, max string, limit int) ([]string, error)

    // Get members of a sorted set by reverse lexicographical order. All members of the set must
    // have been added with a zero score. min and max must begin with '(' or '[' to indicate
    // exclusive or inclusive. Alternatively, min can be "-" and max can be "+" to represent
    // infinities.
    ZRevRangeByLex(key string, min, max string, limit int) ([]string, error)
}

type BatchOperation Uses

type BatchOperation interface {
    Get(key string) GetResult
    Delete(key string) ErrorResult
    Set(key string, value interface{}) ErrorResult
    SMembers(key string) SMembersResult
    SAdd(key string, member interface{}, members ...interface{}) ErrorResult
    SRem(key string, member interface{}, members ...interface{}) ErrorResult
    ZAdd(key string, member interface{}, score float64) ErrorResult
    ZRem(key string, member interface{}) ErrorResult
    ZScore(key string, member interface{}) ZScoreResult

    Exec() error
}

type ErrorResult Uses

type ErrorResult interface {
    Result() error
}

type FallbackBatchOperation Uses

type FallbackBatchOperation struct {
    Backend Backend
    // contains filtered or unexported fields
}

FallbackBatchOperation provides a suitable fallback for stores that don't supported optimized batching.

func (*FallbackBatchOperation) Delete Uses

func (op *FallbackBatchOperation) Delete(key string) ErrorResult

func (*FallbackBatchOperation) Exec Uses

func (op *FallbackBatchOperation) Exec() error

func (*FallbackBatchOperation) Get Uses

func (op *FallbackBatchOperation) Get(key string) GetResult

func (*FallbackBatchOperation) SAdd Uses

func (op *FallbackBatchOperation) SAdd(key string, member interface{}, members ...interface{}) ErrorResult

func (*FallbackBatchOperation) SMembers Uses

func (op *FallbackBatchOperation) SMembers(key string) SMembersResult

func (*FallbackBatchOperation) SRem Uses

func (op *FallbackBatchOperation) SRem(key string, member interface{}, members ...interface{}) ErrorResult

func (*FallbackBatchOperation) Set Uses

func (op *FallbackBatchOperation) Set(key string, value interface{}) ErrorResult

func (*FallbackBatchOperation) ZAdd Uses

func (op *FallbackBatchOperation) ZAdd(key string, member interface{}, score float64) ErrorResult

func (*FallbackBatchOperation) ZRem Uses

func (op *FallbackBatchOperation) ZRem(key string, member interface{}) ErrorResult

func (*FallbackBatchOperation) ZScore Uses

func (op *FallbackBatchOperation) ZScore(key string, member interface{}) ZScoreResult

type GetResult Uses

type GetResult interface {
    Result() (*string, error)
}

type SMembersResult Uses

type SMembersResult interface {
    Result() ([]string, error)
}

type ScoredMember Uses

type ScoredMember struct {
    Score float64
    Value string
}

type ScoredMembers Uses

type ScoredMembers []*ScoredMember

func (ScoredMembers) Values Uses

func (m ScoredMembers) Values() []string

type ZScoreResult Uses

type ZScoreResult interface {
    Result() (*float64, error)
}

Directories

PathSynopsis
dynamodbstore
keyvaluestorecache
keyvaluestoretest
memorystore
redisstore

Package keyvaluestore imports 2 packages (graph) and is imported by 5 packages. Updated 2019-08-13. Refresh now. Tools for package owners.