core

package
v0.0.0-...-d20dd18 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

Core provides an interface to access local stored chunks

func New

func New(dbpath string, chunkSize uint64, numChunks int) *Core

New creates a new server core instance dbpath is the path to store the DB, dbpath="" means RAM only chunkSize is the size in bytes of the chunk numChunks is the number of chunks of the DB Every chunk will be disabled (present flag = false)

func (*Core) BackwardsIterate

func (c *Core) BackwardsIterate(chunkIndex int, foreach func(key, value []byte) bool) error

Iterate all key-value pairs of a chunk in backwards direction, executing foreach for each key-value pair it will stop early if foreach returns false

func (*Core) CAS

func (c *Core) CAS(key, value []byte, isSynced func(chunkIndex int) bool) error

CAS makes an Compare And Swap operation isSynced should return true if the chunk is synced value uses a special convention, see package pmap

func (*Core) ChunkSetNoPresent

func (c *Core) ChunkSetNoPresent(cid int)

ChunkSetNoPresent disables the present flag of a chunk

func (*Core) ChunkSetPresent

func (c *Core) ChunkSetPresent(cid int)

ChunkSetPresent enables the present flag of a chunk

func (*Core) ChunkSetProtected

func (c *Core) ChunkSetProtected(cid int) error

ChunkSetProtected enables the protected flag of a chunk The flag will be disabled automatically after a period of time

func (*Core) Close

func (c *Core) Close()

Close will close the DB, flushing all changes to disk

func (*Core) Delete

func (c *Core) Delete(key, value []byte) error

Delete deletes the pair indexed by key

func (*Core) Get

func (lh *Core) Get(key []byte) ([]byte, error)

Get gets the value for the provided key

func (*Core) IsPresent

func (c *Core) IsPresent(id int) bool

IsPresent returns true if the chunk is present, false otherwise

func (*Core) IsProtected

func (c *Core) IsProtected(id int) bool

IsPresent returns true if the chunk is protected, false otherwise

func (*Core) Iterate

func (c *Core) Iterate(chunkIndex int, foreach func(key, value []byte) bool) error

Iterate all key-value pairs of a chunk, executing foreach for each key-value pair it will stop early if foreach returns false

func (*Core) LengthOfChunk

func (c *Core) LengthOfChunk(chunkIndex int) uint64

LengthOfChunk returns the number of bytes used in the store, or math.MaxUint64 if the chunk isn't present

func (*Core) Open

func (c *Core) Open()

Open will open an already stored DB, Open should be called after New

func (*Core) PresentChunks

func (c *Core) PresentChunks() int

Returns the number of present chunks

func (*Core) PresentChunksList

func (c *Core) PresentChunksList() []protocol.AmAliveChunk

Returns the list of present chunk IDs

func (*Core) Set

func (c *Core) Set(key, value []byte) (err error)

Set sets the value for the provided key

Directories

Path Synopsis
Package pmap provides persistent dictionaries with high-performance access and specific timestamp semantics.
Package pmap provides persistent dictionaries with high-performance access and specific timestamp semantics.

Jump to

Keyboard shortcuts

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