Documentation ¶
Overview ¶
Package storage provides the Storage interface and implementation. aof_storage.go is the implementation of aofStorage. aofStorage is a append-only file storage.
Package storage provides the Storage interface and implementation. error.go defines the error of storage
Package storage provides the Storage interface and implementation. storage.go defines the Storage interface
Index ¶
Constants ¶
View Source
const (
// DefaultAOFDir is the default dir of aofStorage
DefaultAOFDir = "./database/"
)
View Source
const ( // StartID is the start log id StartID uint64 = 0 )
Variables ¶
View Source
var ( // ErrBucketCreateFailed is the error when create bucket failed ErrBucketCreateFailed = errors.New("create bucket failed") // ErrBucketNotFound is the error when the bucket not found ErrBucketNotFound = bolt.ErrBucketNotFound // ErrKeyExist is the error when the key already exist ErrKeyExist = errors.New("the key already exist") // ErrSegmentExist is the error when the Bucket already exist ErrSegmentExist = errors.New("the segmentID already exist") )
View Source
var DefaultConfig = &Config{ Dir: DefaultAOFDir, SegmentInterval: defaultSegmentInterval, BatchInterval: defaultBatchInterval, BatchLimit: defaultBatchLimit, MMapSize: defaultInitialMmapSize, }
DefaultConfig will return a default config
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Dir is the file dir to the aofStorage file. Dir string // SegmentInterval is the interval of the bucket SegmentInterval uint64 // BatchInterval is the maximum time before flushing the BatchTx. // default is 100ms BatchInterval time.Duration // BatchLimit is the maximum puts before flushing the BatchTx. // if puts >= BatchLimit, the BatchTx will be flushed. BatchLimit int // MMapSize is the initial size of the mmapped region. Setting this larger than // the potential max db size can prevent writer from blocking reader. MMapSize int // MustBeNewBucket if is true, will return error when create an exist segmentID MustBeNewBucket bool }
Config is the config of aofStorage
type Storage ¶
type Storage interface { // View to get message log // Read-Only transactions View(segmentID, timestamp, sequence uint64) (*types.Message, error) // Insert Create or update a key // If the key already exist it will return Insert(msg *types.Message) (uint64, error) // Update will update a key // If the key not exist it will Create the key Update(bucket, key, value []byte) error // Delete a key from segmentID Delete(bucket, key []byte) error // CreateSegment will create a segment CreateSegment(segmentID uint64) error // DeleteSegment will delete a segment DeleteSegment(segmentID uint64) error }
Storage defines the interface of storage
func NewAOFStorage ¶
NewAOFStorage will create a new aofStorage
Click to show internal directories.
Click to hide internal directories.