mirror of
https://github.com/taigrr/bitcask
synced 2025-01-18 04:03:17 -08:00
* ttl support first commit * imports fix * put api args correction * put options added * upgrade method added * upgrade log added * v0 to v1 migration script added * error assertion added * temp migration dir fix Co-authored-by: yash <yash.chandra@grabpay.com>
28 lines
476 B
Go
28 lines
476 B
Go
package internal
|
|
|
|
import (
|
|
"hash/crc32"
|
|
"time"
|
|
)
|
|
|
|
// Entry represents a key/value in the database
|
|
type Entry struct {
|
|
Checksum uint32
|
|
Key []byte
|
|
Offset int64
|
|
Value []byte
|
|
Expiry *time.Time
|
|
}
|
|
|
|
// NewEntry creates a new `Entry` with the given `key` and `value`
|
|
func NewEntry(key, value []byte, expiry *time.Time) Entry {
|
|
checksum := crc32.ChecksumIEEE(value)
|
|
|
|
return Entry{
|
|
Checksum: checksum,
|
|
Key: key,
|
|
Value: value,
|
|
Expiry: expiry,
|
|
}
|
|
}
|