Documentation
¶
Index ¶
- Constants
- Variables
- func SetPermissions(filename string, perms os.FileMode) error
- type CDB
- type DuplicateMode
- type Iterator
- type Writer
- func (w *Writer) Abort() error
- func (w *Writer) Copy(r *CDB) error
- func (w *Writer) Finalize() error
- func (w *Writer) Put(key, value []byte) error
- func (w *Writer) PutString(key, value string) error
- func (w *Writer) SetDuplicateMode(mode DuplicateMode)
- func (w *Writer) WriteFrom(r io.Reader, mapFormat bool) error
Constants ¶
const ( // HeaderSize is the size of the CDB header (256 hash table pointers) HeaderSize = 2048 // NumTables is the number of hash tables in a CDB file NumTables = 256 )
Variables ¶
var ( // ErrNotFound is returned when a key is not found in the database ErrNotFound = errors.New("key not found") // ErrInvalidFormat is returned when the CDB file is malformed ErrInvalidFormat = errors.New("invalid CDB format") )
Functions ¶
Types ¶
type CDB ¶
type CDB struct {
// contains filtered or unexported fields
}
CDB represents an open CDB database
type DuplicateMode ¶
type DuplicateMode int
DuplicateMode defines how to handle duplicate keys
const ( // DuplicateModeAllow allows duplicate keys (default) DuplicateModeAllow DuplicateMode = iota // DuplicateModeWarn allows duplicates but warns DuplicateModeWarn // DuplicateModeError rejects duplicates with an error DuplicateModeError // DuplicateModeReplace replaces existing key with new value DuplicateModeReplace // DuplicateModeUnique ignores duplicate keys (keeps first) DuplicateModeUnique // DuplicateModeZeroFill zero-fills duplicate records DuplicateModeZeroFill )
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator provides sequential access to all records in a CDB database
func NewIterator ¶
NewIterator creates a new iterator for sequential scanning of the database
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is used to create CDB databases
func Create ¶
Create creates a new CDB writer If tempFile is empty, finalFile + ".tmp" will be used If tempFile is "-", the file will be created in-place (no temp file)
func (*Writer) Finalize ¶
Finalize completes the database creation by writing hash tables and atomically renaming. The atomic rename ensures that readers with the old file open continue to work, while new opens immediately see the new version. This allows zero-downtime updates.
func (*Writer) SetDuplicateMode ¶
func (w *Writer) SetDuplicateMode(mode DuplicateMode)
SetDuplicateMode sets how duplicate keys should be handled