Documentation ¶
Index ¶
- Constants
- Variables
- type Config
- type DataType
- type FlashDB
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Delete(key string) error
- func (tx *Tx) Exists(key string) bool
- func (tx *Tx) Expire(key string, duration int64) (err error)
- func (tx *Tx) Get(key string) (val string, err error)
- func (tx *Tx) HClear(key string) (err error)
- func (tx *Tx) HDel(key string, field ...string) (res int, err error)
- func (tx *Tx) HExists(key, field string) (ok bool)
- func (tx *Tx) HExpire(key string, duration int64) (err error)
- func (tx *Tx) HGet(key string, field string) string
- func (tx *Tx) HGetAll(key string) []string
- func (tx *Tx) HKeyExists(key string) (ok bool)
- func (tx *Tx) HKeys(key string) (val []string)
- func (tx *Tx) HLen(key string) int
- func (tx *Tx) HSet(key string, field string, value string) (res int, err error)
- func (tx *Tx) HTTL(key string) (ttl int64)
- func (tx *Tx) HVals(key string) (values []string)
- func (tx *Tx) Rollback() error
- func (tx *Tx) SAdd(key string, members ...string) (err error)
- func (tx *Tx) SCard(key string) int
- func (tx *Tx) SClear(key string) (err error)
- func (tx *Tx) SDiff(keys ...string) (values []string)
- func (tx *Tx) SExpire(key string, duration int64) (err error)
- func (tx *Tx) SIsMember(key string, member string) bool
- func (tx *Tx) SKeyExists(key string) (ok bool)
- func (tx *Tx) SMembers(key string) (values []string)
- func (tx *Tx) SMove(src, dst string, member string) error
- func (tx *Tx) SRandMember(key string, count int) (values []string)
- func (tx *Tx) SRem(key string, members ...string) (res int, err error)
- func (tx *Tx) STTL(key string) (ttl int64)
- func (tx *Tx) SUnion(keys ...string) (values []string)
- func (tx *Tx) Set(key string, value string) error
- func (tx *Tx) SetEx(key string, value string, duration int64) (err error)
- func (tx *Tx) TTL(key string) (ttl int64)
- func (tx *Tx) ZAdd(key string, score float64, member string) error
- func (tx *Tx) ZCard(key string) int
- func (tx *Tx) ZClear(key string) (err error)
- func (tx *Tx) ZExpire(key string, duration int64) (err error)
- func (tx *Tx) ZGetByRank(key string, rank int) []interface{}
- func (tx *Tx) ZKeyExists(key string) (ok bool)
- func (tx *Tx) ZRange(key string, start, stop int) []interface{}
- func (tx *Tx) ZRangeWithScores(key string, start, stop int) []interface{}
- func (tx *Tx) ZRank(key string, member string) int64
- func (tx *Tx) ZRem(key string, member string) (ok bool, err error)
- func (tx *Tx) ZRevGetByRank(key string, rank int) []interface{}
- func (tx *Tx) ZRevRange(key string, start, stop int) []interface{}
- func (tx *Tx) ZRevRangeWithScores(key string, start, stop int) []interface{}
- func (tx *Tx) ZRevRank(key string, member string) int64
- func (tx *Tx) ZRevScoreRange(key string, max, min float64) []interface{}
- func (tx *Tx) ZScore(key string, member string) (ok bool, score float64)
- func (tx *Tx) ZScoreRange(key string, min, max float64) []interface{}
- func (tx *Tx) ZTTL(key string) (ttl int64)
Constants ¶
const ( DefaultAddr = "127.0.0.1:8000" DefaultMaxKeySize = uint32(1 * 1024) DefaultMaxValueSize = uint32(8 * 1024) )
const ( MinimumStartupTime = 500 * time.Millisecond MaximumStartupTime = 2 * MinimumStartupTime )
const ( StringRecord uint16 = iota HashRecord SetRecord ZSetRecord )
const ( StringSet uint16 = iota StringRem StringExpire )
The operations on Strings.
const ( HashHSet uint16 = iota HashHDel HashHClear HashHExpire )
The operations on Hash.
const ( SetSAdd uint16 = iota SetSRem SetSMove SetSClear SetSExpire )
The operations on Set.
const ( ZSetZAdd uint16 = iota ZSetZRem ZSetZClear ZSetZExpire )
The operations on Sorted Set.
Variables ¶
var ( ErrInvalidKey = errors.New("invalid key") ErrInvalidTTL = errors.New("invalid ttl") ErrExpiredKey = errors.New("key has expired") ErrTxClosed = errors.New("tx closed") ErrDatabaseClosed = errors.New("database closed") ErrTxNotWritable = errors.New("tx not writable") )
var (
ErrInvalidEntry = errors.New("invalid entry")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Addr string `json:"addr" toml:"addr"` Path string `json:"path" toml:"path"` // dir path for append-only logs EvictionInterval int `json:"eviction_interval" toml:"eviction_interval"` // in seconds // NoSync disables fsync after writes. This is less durable and puts the // log at risk of data loss when there's a server crash. NoSync bool }
func DefaultConfig ¶
func DefaultConfig() *Config
type FlashDB ¶
type FlashDB struct {
// contains filtered or unexported fields
}
func (*FlashDB) Begin ¶
Begin opens a new transaction. Multiple read-only transactions can be opened at the same time but there can only be one read/write transaction at a time. Attempting to open a read/write transactions while another one is in progress will result in blocking until the current read/write transaction is completed.
All transactions must be closed by calling Commit() or Rollback() when done.
func (*FlashDB) Update ¶
Update executes a function within a managed read/write transaction. The transaction has been committed when no error is returned. In the event that an error is returned, the transaction will be rolled back. When a non-nil error is returned from the function, the transaction will be rolled back and the that error will be return to the caller of Update().
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a transaction on the database. This transaction can either be read-only or read/write. Read-only transactions can be used for retrieving values for keys and iterating through keys and values. Read/write transactions can set and delete keys.
All transactions must be committed or rolled-back when done.
func (*Tx) Commit ¶
Commit writes all changes to disk. An error is returned when a write error occurs, or when a Commit() is called from a read-only transaction.
func (*Tx) HKeyExists ¶
func (*Tx) Rollback ¶
Rollback closes the transaction and reverts all mutable operations that were performed on the transaction such as Set() and Delete().
Read-only transactions can only be rolled back, not committed.
func (*Tx) SKeyExists ¶
SKeyExists returns if the key exists.