Documentation
¶
Index ¶
- type ItemCache
- type LevelDBStorage
- func (ds *LevelDBStorage) CachedStore(key string, data []byte)
- func (ds *LevelDBStorage) CachedStore2(key1 string, data1 []byte, key2 string, data2 []byte)
- func (ds *LevelDBStorage) Close()
- func (ds *LevelDBStorage) DeleteCacheData(id ...string)
- func (ds *LevelDBStorage) DeleteData(id ...string) error
- func (ds *LevelDBStorage) DeleteDataWithPrefix(prefix string) int
- func (ds *LevelDBStorage) FlushCache()
- func (ds *LevelDBStorage) GetData(id string) []byte
- func (ds *LevelDBStorage) GetStats() map[string]interface{}
- func (ds *LevelDBStorage) IsClosed() bool
- func (ds *LevelDBStorage) IterData(prefix string) apis.ItemIterator
- func (ds *LevelDBStorage) StoreData(key string, data []byte) error
- func (ds *LevelDBStorage) WaitFlush()
- type LevelDbItemIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LevelDBStorage ¶
type LevelDBStorage struct {
// contains filtered or unexported fields
}
LevelDBStorage A high level cached structure on top of LevelDB. It caches item storing them into database as multiple large batches later.
func NewLevelDBStorage ¶
func NewLevelDBStorage(cfg *conf.Config) (*LevelDBStorage, error)
NewLevelDBStorage is a constructor of DataStorage.
func (*LevelDBStorage) CachedStore ¶
func (ds *LevelDBStorage) CachedStore(key string, data []byte)
CachedStoreItem stores data into the cache.
func (*LevelDBStorage) CachedStore2 ¶
func (ds *LevelDBStorage) CachedStore2(key1 string, data1 []byte, key2 string, data2 []byte)
CachedStoreItem2 stores two items into the item cache.
func (*LevelDBStorage) Close ¶
func (ds *LevelDBStorage) Close()
Close flushes data on disk and closes database.
func (*LevelDBStorage) DeleteCacheData ¶
func (ds *LevelDBStorage) DeleteCacheData(id ...string)
CachedDeleteData deletes item metadata and payload, affects cache only until flushed.
func (*LevelDBStorage) DeleteData ¶
func (ds *LevelDBStorage) DeleteData(id ...string) error
func (*LevelDBStorage) DeleteDataWithPrefix ¶
func (ds *LevelDBStorage) DeleteDataWithPrefix(prefix string) int
DeleteDataWithPrefix deletes all service data such as service metadata, items and payloads.
func (*LevelDBStorage) FlushCache ¶
func (ds *LevelDBStorage) FlushCache()
FlushCache flushes all cache into database.
func (*LevelDBStorage) GetData ¶
func (ds *LevelDBStorage) GetData(id string) []byte
GetData looks data looks for and item going through each layer of cache finally looking into database.
func (*LevelDBStorage) GetStats ¶
func (ds *LevelDBStorage) GetStats() map[string]interface{}
func (*LevelDBStorage) IsClosed ¶
func (ds *LevelDBStorage) IsClosed() bool
func (*LevelDBStorage) IterData ¶
func (ds *LevelDBStorage) IterData(prefix string) apis.ItemIterator
IterData returns an iterator over all data with prefix.
func (*LevelDBStorage) StoreData ¶
func (ds *LevelDBStorage) StoreData(key string, data []byte) error
StoreData data directly into the database stores service metadata into database.
func (*LevelDBStorage) WaitFlush ¶
func (ds *LevelDBStorage) WaitFlush()
WaitFlush waits until all data is flushed on disk.
type LevelDbItemIterator ¶
type LevelDbItemIterator struct { Key []byte // Currently selected key. Valid only if the iterator is valid. Value []byte // Currently selected value. Valid only if the iterator is valid. TrimKey []byte // contains filtered or unexported fields }
ItemIterator built on top of LevelDB. It takes into account service name to limit the amount of selected data.
func (*LevelDbItemIterator) Close ¶
func (mi *LevelDbItemIterator) Close()
Close closes iterator. Iterator must be closed!
func (*LevelDbItemIterator) GetKey ¶
func (mi *LevelDbItemIterator) GetKey() []byte
func (*LevelDbItemIterator) GetTrimKey ¶
func (mi *LevelDbItemIterator) GetTrimKey() []byte
func (*LevelDbItemIterator) GetValue ¶
func (mi *LevelDbItemIterator) GetValue() []byte
func (*LevelDbItemIterator) Next ¶
func (mi *LevelDbItemIterator) Next()
Next switches to the next element.
func (*LevelDbItemIterator) Valid ¶
func (mi *LevelDbItemIterator) Valid() bool
Valid returns true if the current value is OK, otherwise false.
for iter.Valid() { mykey := iter.Key myvalue := iter.Value ...... iter.Next() }