Documentation
¶
Overview ¶
maintain a memory pool of a number of elements
This maintains an in memory LRU list upto a fixed number of elements and permanently store the data in LevelDB.
Index ¶
- Constants
- func Finalise()
- func Initialise(database string)
- type Element
- type FetchCursor
- type IndexedPool
- func (p *IndexedPool) Add(key []byte, value []byte) (bool, error)
- func (p *IndexedPool) Flush() error
- func (p *IndexedPool) Get(key []byte) ([]byte, error)
- func (p *IndexedPool) Recent(start *gnomon.Cursor, count int, ...) ([]interface{}, *gnomon.Cursor, error)
- func (p *IndexedPool) Remove(key []byte) error
- type Iterator
- type Pool
Constants ¶
const ( // networking pools Peers = nameb('P') RPCs = nameb('R') Certificates = nameb('C') // transaction data pools TransactionData = nameb('T') TransactionState = nameb('S') // transaction index pools PendingIndex = nameb('U') VerifiedIndex = nameb('V') // asset AssetData = nameb('I') // ownership indexes OwnerIndex = nameb('O') // blocks BlockData = nameb('B') // just for testing TestData = nameb('Z') )
Names of the pools
Variables ¶
This section is empty.
Functions ¶
func Initialise ¶
func Initialise(database string)
open up the database connection
this must be called before any pool.New() is created
Types ¶
type FetchCursor ¶
type FetchCursor struct {
// contains filtered or unexported fields
}
cursor structure
func (*FetchCursor) Fetch ¶
func (cursor *FetchCursor) Fetch(count int) ([]Element, error)
fetch some elements starting from key
func (*FetchCursor) Seek ¶
func (cursor *FetchCursor) Seek(key []byte) *FetchCursor
type IndexedPool ¶
the pool handle
func NewIndexed ¶
func NewIndexed(prefix nameb) *IndexedPool
create a new indexed pool with a specific key prefix
Separate indexes are created to provide a timestamp ordering
func (*IndexedPool) Add ¶
func (p *IndexedPool) Add(key []byte, value []byte) (bool, error)
add a key/value bytes pair to the database
func (*IndexedPool) Get ¶
func (p *IndexedPool) Get(key []byte) ([]byte, error)
read a value for a given key
func (*IndexedPool) Recent ¶
func (p *IndexedPool) Recent(start *gnomon.Cursor, count int, convert func(key []byte, value []byte) interface{}) ([]interface{}, *gnomon.Cursor, error)
fetch the N most recent string key and data pairs
func (*IndexedPool) Remove ¶
func (p *IndexedPool) Remove(key []byte) error
remove a key from the database
type Pool ¶
the pool handle
func New ¶
func New(prefix nameb) *Pool
create a new pool with a specific key prefix an optional local memory cache
func (*Pool) Get ¶
read a value for a given key
this returns the actual element - copy it if you need to returns "found" as boolean
func (*Pool) LastElement ¶
get the last element in a pool
func (*Pool) NewFetchCursor ¶
func (p *Pool) NewFetchCursor() *FetchCursor
initialise a cursor to the start of a key range