import { ReplicaCache } from "https://deno.land/x/earthstar@v10.0.0-alpha.4/src/replica/replica_cache.ts";
A cached, synchronous interface to a replica, useful for reactive abstractions. Always returns results from its cache, and proxies the query to the backing replica in case of a cache miss.
const cache = new ReplicaCache(myReplica);
const pngQuery = { filter: { pathEndsWith: ".png" } };
let pngDocs = cache.queryDocs(pngQuery);
cache.onCacheUpdate(() => {
pngDocs = cache.queryDocs(pngQuery);
});
Constructors
Properties
Methods
Fetch all versions of all docs from the cache. Returns an empty array in case of a cache miss, and queries the backing replica.
Fetch all versions of all docs from a certain path from the cache. Returns an empty array in case of a cache miss, and queries the backing replica.
Fetch latest version of a doc at a path from the cache. Returns an empty array in case of a cache miss, and queries the backing replica.
Fetch latest versions of all docs from the cache. Returns an empty array in case of a cache miss, and queries the backing replica.
Subscribes to the cache, calling a callback when previously returned results can be considered stale. Returns a function for unsubscribing.
Call this method on the backing replica.
Returns an array of all unique authors of documents returned by a given query.
Fetch docs matching a query from the cache. Returns an empty array in case of a cache miss, and queries the backing replica.
Returns an array of all unique paths of documents returned by a given query.
Add a new document directly to the backing replica.