MCPcopy Index your code
hub / github.com/directus/directus / getCacheValueWithTTL

Function getCacheValueWithTTL

api/src/cache.ts:184–196  ·  view source on GitHub ↗
(
	cache: Keyv,
	key: string,
)

Source from the content-addressed store, hash-verified

182 * Get a cached value along with its remaining TTL
183 */
184export async function getCacheValueWithTTL(
185 cache: Keyv,
186 key: string,
187): Promise<{ data: any; remainingTTL: number } | undefined> {
188 const value = await getCacheValue(cache, key);
189
190 if (!value) return undefined;
191
192 const expiryData = await getCacheValue(cache, `${key}__expires_at`);
193 const remainingTTL = expiryData?.exp ? Math.max(0, expiryData.exp - Date.now()) : 0;
194
195 return { data: value, remainingTTL };
196}
197
198function getKeyvInstance(store: Store, ttl: number | undefined, namespaceSuffix?: string): Keyv {
199 switch (store) {

Callers 2

listProviderProjectsMethod · 0.85
getProviderProjectMethod · 0.85

Calls 1

getCacheValueFunction · 0.85

Tested by

no test coverage detected