HiveInstances class
One Hive instance per storage path.
Why this exists. A Hive box's identity is (instance registry, box name). Both the registry and the home path are instance fields of
HiveImpl — package:hive merely exposes one global instance
(final HiveInterface Hive = HiveImpl();), and everything in this package
used to run through it. So the path a store was given reached
Hive.init(...), a process-wide setting that the next store overwrote, and
the box itself was opened by name alone.
Box names here derive from the atSign, so two stores for one atSign in one
process always collided however different the paths they were handed: the
second silently attached to the first's box, and its own storagePath
reached nothing but the encryption-secret file beside it.
Why the instance is shared per path rather than created per store. Two instances over one directory do not throw and do not lock each other out. They open two independent boxes over the same files, whose in-memory views then diverge silently — measured: after writing through the second, the first still read its own older value. Sharing by path is what keeps same-path callers on exactly one box, which is what they have always had.
What this changes for an existing deployment: nothing. A process whose stores all use one path resolves to one instance and opens the same box files under the same names. No box is renamed and no data moves. Only a caller that asks for a different path sees a difference — it now gets the separate store it asked for.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instanceCount → int
-
Instances built so far, for tests that assert the sharing rule.
no setter
Static Methods
-
canonicalPathFor(
String storagePath, {bool create = true}) → String - How two spellings of one directory are recognised as one.
-
closeAll(
) → Future< void> - Closes every box this registry has opened, and forgets the instances.
-
closeFor(
String storagePath) → Future< void> -
Closes and forgets the instance owning
storagePath, if there is one. -
forPath(
String storagePath) → HiveInterface -
The instance owning
storagePath, created on first use.