Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteStore(dir string) error
- func NextPowerOf2(v uint32) (power byte, val uint32)
- type Header
- type OptStore
- type Store
- func (s *Store) Backup(w io.Writer) (err error)
- func (s *Store) BackupGZ(w io.Writer) (err error)
- func (s *Store) Bucket(name string) (*sortedset.BucketStore, error)
- func (s *Store) Close() (err error)
- func (s *Store) Count() (cnt int)
- func (s *Store) Decr(k []byte, v uint64) (uint64, error)
- func (s *Store) Delete(k []byte) (isDeleted bool, err error)
- func (s *Store) Expire() (err error)
- func (s *Store) FileSize() (fs int64, err error)
- func (s *Store) Get(k []byte) (v []byte, err error)
- func (s *Store) Incr(k []byte, v uint64) (uint64, error)
- func (s *Store) Keys(bucket *sortedset.BucketStore, limit, offset int) []string
- func (s *Store) Put(bucket *sortedset.BucketStore, k, v []byte) (err error)
- func (s *Store) Restore(r io.Reader) (err error)
- func (s *Store) RestoreGZ(r io.Reader) (err error)
- func (s *Store) Set(k, v []byte, expire uint32) (err error)
- func (s *Store) Touch(k []byte, expire uint32) (err error)
Constants ¶
const Version = "0.4.1"
Variables ¶
var ErrCollision = errors.New("Error, hash collision")
ErrCollision - must not happen
var ErrFormat = errors.New("Error, unexpected file format")
ErrFormat unexpected file format
var ErrNotFound = errors.New("Error, key not found")
ErrNotFound key not found error
Functions ¶
func NextPowerOf2 ¶
NextPowerOf2 return next power of 2 for v and it's value return maxuint32 in case of overflow
Types ¶
type OptStore ¶ added in v0.2.0
OptStore is a store options
func ChunksCollision ¶ added in v0.3.0
ChunksCollision - number chunks for collisions resolving, default is 4 (>1_000_000_000 of 8 bytes alphabet keys without collision errors) different keys may has same hash collision chunks needed for resolving this, without collisions errors if ChunkColCnt - zero, ErrCollision will return in case of collision
func ChunksPrefix ¶ added in v0.4.0
ChunksPrefix - prefix for a chunks filename
func ChunksTotal ¶ added in v0.3.0
ChunksTotal - total chunks/shards, default 256 Must be more then collision chunks
func ExpireInterval ¶ added in v0.3.0
ExpireInterval - how often run key expiration process expire only one chunk
func SyncInterval ¶ added in v0.1.8
SyncInterval - how often fsync do, default 0 - OS will do it
type Store ¶
Store struct data in store sharded by chunks
func Open ¶
Open return new store It will create 256 shards Each shard store keys and val size and address in map[uint32]uint32
options, see https://gist.github.com/travisjeffery/8265ca411735f638db80e2e34bdbd3ae#gistcomment-3171484 usage - Open(Dir("1"), SyncInterval(1*time.Second))
func (*Store) Bucket ¶ added in v0.3.0
func (s *Store) Bucket(name string) (*sortedset.BucketStore, error)
Bucket - create new bucket for storing keys with same prefix in memory index
func (*Store) Keys ¶ added in v0.3.0
func (s *Store) Keys(bucket *sortedset.BucketStore, limit, offset int) []string
Keys will return keys stored with Put method Params: key prefix ("" - return all keys) Limit - 0, all Offset - 0, zero offset Keys will be without prefix and in descending order
func (*Store) Put ¶ added in v0.3.0
func (s *Store) Put(bucket *sortedset.BucketStore, k, v []byte) (err error)
Put - store key and val with Set And add key in index (backed by sortedset)