Struct bonsaidb_core::key::time::limited::BonsaiEpoch
source · pub struct BonsaiEpoch;
Expand description
A TimeEpoch
implementation that allows storing
LimitedResolutionTimestamp
relative to the 10-year anniversary of
BonsaiDb: March 20, 2031 04:31:47 UTC.
Why use BonsaiEpoch
instead of UnixEpoch
?
LimitedResolutionTimestamp
uses [ordered-varint::Variable
] to
implement Key
, which encodes the underlying value in as few bytes as
possible while still preserving the ordering required by Key
.
Many applications are not storing timestamps that predate the
application being developed. When there is a likelihood that timestamps
are closer to “now” than they are to the unix timestamp (January 1, 1970
00:00:00 UTC), the BonsaiEpoch
will consistently encode the
underlying representation in fewer bytes than when using UnixEpoch
.
We hope BonsaiDb is a viable database option for many years. By setting this epoch 10 years from the start of BonsaiDb, it allows the internal representation of timestamps to slowly decrease in size until the 10-year anniversary. Over the following 10 years, the size will grow back to the same size it was at its conception, and then slowly grow as needed from that point on.
Trait Implementations§
source§impl TimeEpoch for BonsaiEpoch
impl TimeEpoch for BonsaiEpoch
source§fn name() -> &'static str
fn name() -> &'static str
KeyEncoding::describe
to
disambiguate timestamps with different epochs.source§fn epoch_offset() -> Duration
fn epoch_offset() -> Duration
UNIX_EPOCH
for this epoch.