Documentation ¶
Overview ¶
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 "go.chromium.org/luci/gae/impl/memory".
Index ¶
- type Collection
- func (c *Collection) Delete(i gtreap.Item)
- func (c *Collection) Get(i gtreap.Item) gtreap.Item
- func (c *Collection) IsReadOnly() bool
- func (c *Collection) Iterator(pivot gtreap.Item) *gtreap.Iterator
- func (c *Collection) Max() gtreap.Item
- func (c *Collection) Min() gtreap.Item
- func (c *Collection) Name() string
- func (c *Collection) Put(i gtreap.Item)
- func (c *Collection) VisitAscend(pivot gtreap.Item, visitor gtreap.ItemVisitor)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) 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 github.com/steveyen/gtreap 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 (*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 ¶
GetCollectionNames returns the names of the Collections in this Store, sorted alphabetically.
func (*Store) IsReadOnly ¶
IsReadOnly returns true if this Store is read-only.