Complete redo of content indexing and querying (#517)
Complete redo of data store Introduces live queries and live templates
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import "$sb/lib/fetch.ts";
|
||||
import { federatedPathToUrl } from "$sb/lib/resolve.ts";
|
||||
import { readFederationConfigs } from "./config.ts";
|
||||
import { store } from "$sb/syscalls.ts";
|
||||
import { datastore } from "$sb/syscalls.ts";
|
||||
import type { FileMeta } from "$sb/types.ts";
|
||||
|
||||
async function responseToFileMeta(
|
||||
@@ -29,7 +29,7 @@ async function responseToFileMeta(
|
||||
};
|
||||
}
|
||||
|
||||
const fileListingPrefixCacheKey = `federationListCache:`;
|
||||
const fileListingPrefixCacheKey = `federationListCache`;
|
||||
const listingCacheTimeout = 1000 * 30;
|
||||
const listingFetchTimeout = 2000;
|
||||
|
||||
@@ -56,8 +56,8 @@ export async function listFiles(): Promise<FileMeta[]> {
|
||||
}
|
||||
|
||||
export async function cacheFileListing(uri: string): Promise<FileMeta[]> {
|
||||
const cachedListing = await store.get(
|
||||
`${fileListingPrefixCacheKey}${uri}`,
|
||||
const cachedListing = await datastore.get(
|
||||
[fileListingPrefixCacheKey, uri],
|
||||
) as FileListingCacheEntry;
|
||||
if (
|
||||
cachedListing &&
|
||||
@@ -99,7 +99,7 @@ export async function cacheFileListing(uri: string): Promise<FileMeta[]> {
|
||||
perm: "ro",
|
||||
name: `${rootUri}/${meta.name}`,
|
||||
}));
|
||||
await store.set(`${fileListingPrefixCacheKey}${uri}`, {
|
||||
await datastore.set([fileListingPrefixCacheKey, uri], {
|
||||
items,
|
||||
lastUpdated: Date.now(),
|
||||
} as FileListingCacheEntry);
|
||||
|
||||
Reference in New Issue
Block a user