Documentation
¶
Overview ¶
Package storage implements an off-heap data store which is memory within the runtime that is not subject to Go garbage collection.
Index ¶
- Variables
- type Storage
- func (s *Storage) Check(hkey uint64) bool
- func (s *Storage) Close() error
- func (s *Storage) Delete(hkey uint64) error
- func (s *Storage) Export() ([]byte, error)
- func (s *Storage) Get(hkey uint64) (*VData, error)
- func (s *Storage) GetRaw(hkey uint64) ([]byte, error)
- func (s *Storage) Len() int
- func (s *Storage) Put(hkey uint64, value *VData) error
- func (s *Storage) PutRaw(hkey uint64, value []byte) error
- func (s *Storage) Range(f func(hkey uint64, vdata *VData) bool)
- type VData
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyTooLarge is an error that indicates the given key is large than the determined key size. // The current maximum key length is 256. ErrKeyTooLarge = errors.New("key too large") // ErrKeyNotFound is an error that indicates that the requested key could not be found in the DB. ErrKeyNotFound = errors.New("key not found") )
var ErrFragmented = errors.New("storage fragmented")
ErrFragmented is an error that indicates this storage instance is currently fragmented and it cannot be serialized.
Functions ¶
This section is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage implements a new off-heap data store which uses built-in map to keep metadata and mmap syscall for allocating memory to store values. The allocated memory is not a subject of Golang's GC.
func (*Storage) Close ¶
Close closes underlying tables and releases allocated memory with Munmap. It blocks until everything is done.
func (*Storage) Delete ¶
Delete deletes the value for the given key. Delete will not returns error if key doesn't exist.
func (*Storage) Export ¶
Export serializes underlying data structes into a byte slice. It may return ErrFragmented if the tables are fragmented. If you get this error, you should try to call Export again some time later.
func (*Storage) Get ¶
Get gets the value for the given key. It returns ErrKeyNotFound if the DB does not contains the key. The returned VData is its own copy, it is safe to modify the contents of the returned slice.
func (*Storage) GetRaw ¶
GetRaw extracts un-decoded value for the given hkey. This is useful for merging tables or snapshots.
func (*Storage) Put ¶
Put sets the value for the given key. It overwrites any previous value for that key