HiveAtNotificationKeystore class
Hive-backed implementation of AtNotificationKeystore: a queue of pending atSign-to-atSign notifications, persisted server-side.
- Implemented types
Constructors
- HiveAtNotificationKeystore(String currentAtSign, {int compactionPercentage = 30})
-
You must subsequently call
init - HiveAtNotificationKeystore.getInstance()
-
factory
Properties
-
changes
→ Stream<
KeyStoreChange> -
Broadcast stream of
KeyStoreChangeevents — one per successful mutation that affects the key set or stored value. Late subscribers do not receive earlier events.no setteroverride - compactionPercentage → int
-
Per-pass percentage of entries to drop when compaction is
invoked. Captured from
AtSecondaryConfigat factory time.final - currentAtSign ↔ String
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
postRemoveHooks
↔ List<
Future< void> Function(String key, {required bool skipCommit})> -
Hooks invoked synchronously after a single-key remove. Each
hook is awaited in order. Hook exceptions are propagated to
the caller after the remove has already happened.
getter/setter pairoverride-getter
-
preRemoveHooks
↔ List<
Future< void> Function(String key, {required bool skipCommit})> -
Hooks invoked synchronously before a single-key remove. Each
hook is awaited in order; if a hook throws, the remove is
aborted and the exception propagates.
getter/setter pairoverride-getter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- storagePath ↔ String
-
getter/setter pairinherited
- supportsSnapshots → bool
-
truewhen this keystore can produce real isolated snapshots (snapshot returns a handle whose reads observe the keystore's state at snapshot-creation time, ignoring concurrent writes).falsewhen the handle delegates to live state (Hive backends).no setteroverride
Methods
-
clear(
) → Future< void> - Drop every entry from the underlying box AND the in-memory expiry index, without closing the box. Used by AtPersistenceBundle.clear for cheap test isolation.
-
close(
) → Future< void> -
inherited
-
compact(
bool dryRun) → Stream< String> -
Compact the notification queue. Drops every expired
notification — those are the only entries that ever leave the
queue this way.
override
-
create(
String key, AtNotification value, {bool skipCommit = false}) → Future< int?> -
If no mapping exists for
key, associates it withvalueand returns the commit-log sequence number; otherwise behaviour is implementation-defined (typically throws).override -
deleteExpiredKeys(
) → Future< bool> -
Removes all expired keys. Deletes are local-only — they are
NOT appended to the commit log, so an expiry sweep never
advances the local
commitIdand never propagates to other secondaries via sync. Expiry is treated as backend maintenance, not a sync-worthy mutation; clients drop expired keys independently using their own TTL bookkeeping.override -
entriesCount(
) → int -
Total entry count. Used by operators / metrics.
override
-
exists(
String key) → Future< bool> -
Returns
trueif the keystore currently containskey, elsefalse. The backend-agnostic existence check — the same call site works against every backend.override -
get(
String key) → Future< AtNotification?> -
Retrieves the value mapped to
key, ornullif no mapping exists. Implementations may also throw a backend-specific not-found exception (e.g.KeyNotFoundException) instead of returningnull— consult the concrete impl.override -
getBox(
) → BoxBase -
inherited
-
getExpiredKeys(
) → Future< Stream< String> > -
Streams all keys that have expired. The returned
Futurecompletes once the backend has accepted the request (surfacing any setup failure eagerly); theStreamthen yields the keys.override -
getKeys(
{String? regex}) → Future< Stream< String> > -
Streams the keys, optionally filtered by
regex. The returnedFuturecompletes once the backend has accepted the request — setup failures (store not open, invalidregex) reject theFutureeagerly rather than surfacing mid-stream; theStreamthen yields the matching keys.override -
getMany(
List< String> keys) → Future<Map< String, AtNotification> > -
Bulk fetch — returns the values for every key in
keysthat is currently present. Keys that are absent are NOT included in the returned map.override -
getSize(
) → int -
Size of this store's on-disk footprint, in KB. Sums the lengths
of every file under
storagePathwhose name starts with the box name (Hive writes<boxName>.hiveand<boxName>.lock). The previous impl summed the WHOLEstoragePathdirectory, which double-counts whenever multiple boxes share a directory (which they do on the secondary).inherited -
getValue(
dynamic key) → Future< AtNotification?> -
inherited
-
getValues(
) → Future< List> - Returns a list of atNotification sorted on notification date time.
-
init(
String storagePath, {bool isLazy = true}) → Future< void> -
inherited
-
initialize(
) → Future< void> -
Subclasses should put any necessary post-construction async
initialization in this method.
override
-
isEmpty(
) → bool -
iterate(
) → Stream< AtNotification> -
Iterate every notification entry. Used by the persistence
migrator to copy notification content from one backend to
another.
override
-
nextExpiresAt(
) → Future< DateTime?> -
Smallest non-null expiry instant across all entries, or
nullif no entry has one set. Drives expiry-cron wake-up: a caller can sleep until the returned time, then call peekExpired or deleteExpiredKeys to drain.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openBox(
String boxName, {List< int> ? hiveSecret}) → Future<void> -
inherited
-
peekExpired(
{DateTime? asOf, int? limit}) → Future< Stream< String> > -
Up to
limitkeys whose expiry instant is at-or-beforeasOf(default: now), in ascending-expiry order.limit: 1answers "which key is next to expire".limit: nullmeans no limit — the same set as getExpiredKeys, but with guaranteed ascending-expiry ordering. Ties (same expiry instant) are yielded in implementation-defined order.override -
put(
String key, AtNotification value, {bool skipCommit = false}) → Future< int?> -
Associates
valuewithkey. If a mapping already exists, the old value is replaced.override -
remove(
String key, {bool skipCommit = false}) → Future< int?> -
Removes the mapping for
keyif present.override -
removeMany(
List keys, {bool skipCommit = false}) → Future< int> -
Bulk delete — removes every key in
keys. Returns the count of keys actually removed (race-tolerant: input keys may already have been deleted).override -
snapshot(
) → Future< KeyStoreSnapshot< String, AtNotification, dynamic> > -
Take a snapshot of the keystore's current state. Always
releasethe handle when done.override -
stats(
) → Future< KeyStoreStats> -
Diagnostic snapshot of the keystore's state — total counts,
TTL/TTB key counts, approximate size, oldest/newest
timestamps. Intended for operator dashboards, not for
runtime decisions on a hot path.
override
-
toString(
) → String -
A string representation of this object.
override
-
transaction<
R> (Future< R> body(KeyStoreTxn<String, AtNotification, dynamic> txn)) → Future<R> -
Run
bodyas a transaction. Mutations performed via the supplied handle are buffered in memory and applied in body order on successful completion; if the body throws, the buffer is dropped and the exception propagates.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- maxKeyLengthWithoutCached → const int