Documentation
¶
Index ¶
Constants ¶
const DefaultDbFile string = "dump.scdb"
DefaultDbFile is the default name of the database file that contains all the key-value pairs
Variables ¶
var ZeroU64 = internal.Uint64ToByteArray(0)
Functions ¶
This section is empty.
Types ¶
type OpResult ¶
OpResult is the result of an Op done on the Store It is usually pushed to the Op.RespChan so that the sender of the Op can receive the result and act upon it
type Store ¶
type Store struct {
BufferPool *buffers.BufferPool
Header *entries.DbFileHeader
CompactionInterval time.Duration
C chan Op
}
Store is the actual store of the key-value pairs It contains the BufferPool which in turn interfaces with both the memory and the disk to keep, retrieve and delete key-value pairs
func NewStore ¶
func NewStore(path string, maxKeys *uint64, redundantBlocks *uint16, poolCapacity *uint64, compactionInterval *uint32) (*Store, error)
NewStore creates a new Store at the given path, with the given `compactionInterval`
func (*Store) Close ¶
Close frees up any resources occupied by store. After this, the store is unusable. You have to re-instantiate it or just run into some crazy errors
func (*Store) Compact ¶
Compact manually removes dangling key-value pairs in the database file
Dangling keys result from either getting expired or being deleted. When a Store.Delete operation is done, the actual key-value pair is just marked as `deleted` but is not removed.
Something similar happens when a key-value is updated. A new key-value pair is created and the old one is left un-indexed. Compaction is important because it reclaims this space and reduces the size of the database file.
This is done automatically for you at the set `compactionInterval` but you may wish to do it manually for some reason.
This is a very expensive operation so use it sparingly.