ttlstore

package
v0.0.0-...-1204f0f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2016 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLockedSource

func NewLockedSource(seed int64) *lockedSource

Types

type DataStore

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

DataStore is a key store that supports TTL's and LRU eviction.

func New

func New(size int64, logger *log.Logger) (*DataStore, error)

func (*DataStore) Add

func (d *DataStore) Add(key string, value []byte, exp int64, flags int32) error

Add stores the passed value and key metadata only if the key doesn't exist.

func (*DataStore) Append

func (d *DataStore) Append(key string, value []byte) error

Append the value to an existing value.

func (*DataStore) Cas

func (d *DataStore) Cas(key string, value []byte, exp, cas int64, flags int32) error

Cas will set the key to the passed value if the CAS value is correct.

func (*DataStore) Contains

func (d *DataStore) Contains(key string) bool

Contains returns whether the key is stored.

func (*DataStore) Decrement

func (d *DataStore) Decrement(key string, amount int64) (int64, error)

Decrement the key if it was previously set and is a number, will not go below zero. Returns the new value or an error.

func (*DataStore) Delete

func (d *DataStore) Delete(key string) error

Delete removes the key if it was previously set or returns an error.

func (*DataStore) Destroy

func (d *DataStore) Destroy() error

Destroy removes all temp files and cleanly exits all goroutines created.

func (*DataStore) Get

func (d *DataStore) Get(key string) (*KeyData, error)

Get returns the key value or an error if it is not set.

func (*DataStore) Increment

func (d *DataStore) Increment(key string, amount int64) (int64, error)

Increment the key if it was previously set and is a number. Returns the new value or an error.

func (*DataStore) List

func (d *DataStore) List() []string

List returns the set of keys stored.

func (*DataStore) Prepend

func (d *DataStore) Prepend(key string, value []byte) error

Prepend the value to an existing value.

func (*DataStore) Replace

func (d *DataStore) Replace(key string, value []byte, exp int64, flags int32) error

Replace stores the passed value and key metadata only if the key exist.

func (*DataStore) Set

func (d *DataStore) Set(key string, value []byte, exp int64, flags int32) error

Set stores the passed value and key metadata.

func (*DataStore) Touch

func (d *DataStore) Touch(key string, exp int64) error

Touch updates the expiration time of a key. The expiration time is in Unix seconds, but if zero is passed the key will not expire. An error is returned if the key does not exist.

type Item

type Item struct {
	Key  string // The value of the Item; arbitrary.
	Time int64  // The priority of the Item in the queue.
	// contains filtered or unexported fields
}

type KeyData

type KeyData struct {
	Data  []byte
	Flags int32
	Size  int64
	Cas   int64
	Exp   int64
}

type TtlHeap

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

func NewTtlHeap

func NewTtlHeap() *TtlHeap

func (*TtlHeap) Contains

func (t *TtlHeap) Contains(key string) bool

func (*TtlHeap) Peek

func (t *TtlHeap) Peek() (Item, error)

func (*TtlHeap) Pop

func (t *TtlHeap) Pop() (*Item, error)

func (*TtlHeap) Push

func (t *TtlHeap) Push(key string, time int64) error

func (*TtlHeap) Remove

func (t *TtlHeap) Remove(key string) error

func (*TtlHeap) Size

func (t *TtlHeap) Size() int

func (*TtlHeap) Update

func (t *TtlHeap) Update(key string, time int64) error

Jump to

Keyboard shortcuts

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