v0.0.0-...-51f9457 Latest Latest

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 5 Imported by: 0



Package treapstore is a lightweight append-only in-memory key-value store built on top a treap (tree + heap) implementation.

treapstore is specifically focused on supporting the in-memory datastore implementation at "".



This section is empty.


This section is empty.


This section is empty.


type Collection

type Collection struct {
	// contains filtered or unexported fields

Collection is a collection of Items.

Collections belonging to read/write Store instances are, themselves, read/write. Collections belonging to Snapshot instances are read-only.

A Collection's zero value is a valid read-only empty Collection, which is not terribly useful.

func (*Collection) Delete

func (c *Collection) Delete(i gtreap.Item)

Delete deletes an item from the Collection, if such an item exists.

func (*Collection) Get

func (c *Collection) Get(i gtreap.Item) gtreap.Item

Get returns the item in the Store that matches i, or nil if no such item exists.

func (*Collection) IsReadOnly

func (c *Collection) IsReadOnly() bool

IsReadOnly returns true if this Collection is read-only.

func (*Collection) Iterator

func (c *Collection) Iterator(pivot gtreap.Item) *gtreap.Iterator

Iterator returns an iterator over the Collection, starting at the supplied pivot item.

func (*Collection) Max

func (c *Collection) Max() gtreap.Item

Max returns the largest item in the collection.

func (*Collection) Min

func (c *Collection) Min() gtreap.Item

Min returns the smallest item in the collection.

func (*Collection) Name

func (c *Collection) Name() string

Name returns this Collection's name.

func (*Collection) Put

func (c *Collection) Put(i gtreap.Item)

Put adds an item to the Store.

If the Store is read-only, Put will panic.

func (*Collection) VisitAscend

func (c *Collection) VisitAscend(pivot gtreap.Item, visitor gtreap.ItemVisitor)

VisitAscend traverses the Collection ascendingly, invoking visitor for each visited item.

If visitor returns false, iteration will stop prematurely.

VisitAscend is a more efficient traversal than using an Iterator, and is useful in times when entry-by-entry iteration is not required.

type Store

type Store struct {
	// contains filtered or unexported fields

Store is a general-purpose concurrently-accessible copy-on-write store built on top of the treap (tree + heap) implementation.

A Store is composed of a series of named Collection instances, each of which can hold data elements.

A Store is created by calling New, and is initially in a read/write mode. Derivative Stores can be created by calling a Store's Snapshot capability. These Stores will be read-only, meaning their collections and those collections' data data may only be accessed, not modified.

A Store's zero value is a valid read-only empty Store, but is not terribly useful.

func New

func New() *Store

New creates a new read/write Store.

func (*Store) CreateCollection

func (s *Store) CreateCollection(name string, compare gtreap.Compare) *Collection

CreateCollection returns a Collection with the specified name. If the collection already exists, or if s is read-only, CreateCollection will panic.

func (*Store) GetCollection

func (s *Store) GetCollection(name string) *Collection

GetCollection returns the Collection with the specified name. If no such Collection exists, GetCollection will return nil.

func (*Store) GetCollectionNames

func (s *Store) GetCollectionNames() []string

GetCollectionNames returns the names of the Collections in this Store, sorted alphabetically.

func (*Store) IsReadOnly

func (s *Store) IsReadOnly() bool

IsReadOnly returns true if this Store is read-only.

func (*Store) Snapshot

func (s *Store) Snapshot() *Store

Snapshot creates a read-only copy of the Store and all of its Collection instances. Because a Store is copy-on-write, this is a cheap operation.

Jump to

Keyboard shortcuts

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