You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added `ttl` column to `kvmeta` table, with corresponding schema bump
- Accessors for TTL on C4Collection, KeyStore, etc.
- SQLiteKeyStore fetches TTL and lastSequence in a single query,
to avoid an extra query per save.
- `SQLiteKeyStore::set` sets the expiration based on the TTL, if any.
- `CollectionImpl::documentSaved` checks if there's a TTL, and if so
notifies the Housekeeper (just like setExpiration does.)
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved defects break reads on older read-only schemas, prevent TTL renewal on some saves, and carry deleted collections’ TTL settings into recreated collections.
Adds per-collection time-to-live (TTL) support to LiteCore, connecting collection configuration to SQLite-backed document expiration and background cleanup.
Changes:
Persists TTL in collection metadata with a schema upgrade and combined metadata reads.
Exposes TTL through C, C++, and storage APIs.
Applies expiration during saves, notifies housekeeping, and adds persistence and expiration tests.
File
Description
LiteCore/Storage/SQLiteKeyStore.hh
Declares TTL accessors and cached state.
LiteCore/Storage/SQLiteKeyStore.cc
Reads, caches, and applies TTL during writes.
LiteCore/Storage/SQLiteDataFile.hh
Adds combined metadata and the TTL schema version.
LiteCore/Storage/SQLiteDataFile.cc
Creates, migrates, reads, and writes TTL metadata.
LiteCore/Storage/KeyStore.hh
Defines the storage-level TTL interface.
LiteCore/Storage/BothKeyStore.hh
Delegates TTL access to the live store.
LiteCore/Database/CollectionImpl.hh
Exposes TTL and connects saves to housekeeping.
C/tests/c4DatabaseTest.cc
Tests TTL persistence and automatic expiration.
C/scripts/c4.txt
Adds TTL functions to the export list.
C/include/c4Collection.h
Declares and documents public C TTL APIs.
C/include/c4Base.h
Defines millisecond intervals and timestamp addition.
- Don't persist TTL across collection deletion + recreation. Deleting
a collection should delete its row in kvmeta.
- Saving a doc when no new sequence is created (i.e. by replicator)
should also apply the TTL.
- Stopped BothKeyStore from overwriting the expiration set by TTL.
- Prevent SQLite error in getKVMeta() when the database hasn't been
upgraded so kvmeta doesn't have a ttl column.
- Prevent caller setting ridiculously large TTL that would overflow
the expiration_t.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Resetting collection sequences while retaining replication checkpoints can cause push replication to skip new documents when a collection is recreated.
Forward TTL expiration notifications to a housekeeping connection
LiteCore/Database/CollectionImpl.hh:338
openAgain() disables housekeeping on replication's write connection, so this notification cannot start expiry there and is not forwarded to the primary connection. If the primary collection has no active expiry timer, pulled documents receive expiration timestamps but remain unpurged until reopening or another operation starts expiry. Forward TTL-expiration notifications after commit to a housekeeping-enabled connection, starting its expiry task if needed.
- Don't persist TTL across collection deletion + recreation. Deleting
a collection should delete its row in kvmeta.
- Saving a doc when no new sequence is created (i.e. by replicator)
should also apply the TTL.
- Stopped BothKeyStore from overwriting the expiration set by TTL.
- Prevent SQLite error in getKVMeta() when the database hasn't been
upgraded so kvmeta doesn't have a ttl column.
- Prevent caller setting ridiculously large TTL that would overflow
the expiration_t.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
An unconditional null housekeeper dereference causes TTL-enabled saves and positive expiration changes to crash on reopened connections, including those used by replication.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented CBL-9299.
ttlcolumn tokvmetatable, with corresponding schema bumpSQLiteKeyStore::setsets the expiration based on the TTL, if any.CollectionImpl::documentSavedchecks if there's a TTL, and if so notifies the Housekeeper (just like setExpiration does.)