LogoRobo.js
Framework

CacheAdapter<K, V>

Class: CacheAdapter<K, V>

LRU cache wrapper for adapters.

Uses a Map for O(1) access with LRU eviction based on insertion order. Map maintains insertion order, so deleting and re-setting moves to end.

Extends

Type Parameters

Type ParameterDefault type
K extends stringstring
Vunknown

Constructors

new CacheAdapter()

new CacheAdapter<K, V>(adapter, options): CacheAdapter<K, V>

Parameters

ParameterType
adapterFlashcoreAdapter<K, V>
optionsCacheOptions

Returns

CacheAdapter<K, V>

Overrides

AdapterWrapper.constructor

Properties

PropertyModifierTypeDefault valueDescriptionOverridesInherited from
namereadonly"CacheAdapter"'CacheAdapter'Human-readable name for this wrapper. Subclasses should override this.AdapterWrapper.name-
nextreadonlyFlashcoreAdapter<K, V>undefined--AdapterWrapper.next

Accessors

atomicBatch

Get Signature

get atomicBatch(): (ops) => void | Promise<void>

Atomic batch operations. Propagates from underlying adapter if available.

Returns

Function

Parameters
ParameterType
opsBatchOperation<K, V>[]
Returns

void | Promise<void>

Overrides

AdapterWrapper.atomicBatch


compareAndSwap

Get Signature

get compareAndSwap(): (key, expected, next) => boolean | Promise<boolean>

Compare and swap. Propagates from underlying adapter if available.

Returns

Function

Parameters
ParameterType
keyK
expectedV
nextV
Returns

boolean | Promise<boolean>

Inherited from

AdapterWrapper.compareAndSwap


maxValueSize

Get Signature

get maxValueSize(): number

Maximum value size. Propagates from underlying adapter if available.

Returns

number

Maximum size in bytes for a single value. Used for chunk sizing and WAL segmentation.

Inherited from

AdapterWrapper.maxValueSize


scan

Get Signature

get scan(): (prefix) => 
  | K[]
  | Promise<K[]>
  | AsyncIterable<K, any, any>
| Promise<AsyncIterable<K, any, any>>

Scan for keys with a prefix. Propagates from underlying adapter if available.

Returns

Function

Parameters
ParameterType
prefixK
Returns

| K[] | Promise<K[]> | AsyncIterable<K, any, any> | Promise<AsyncIterable<K, any, any>>

Inherited from

AdapterWrapper.scan


setIfNotExists

Get Signature

get setIfNotExists(): (key, value) => boolean | Promise<boolean>

Set if not exists. Propagates from underlying adapter if available.

Returns

Function

Parameters
ParameterType
keyK
valueV
Returns

boolean | Promise<boolean>

Inherited from

AdapterWrapper.setIfNotExists


transaction

Get Signature

get transaction(): (fn) => Promise<void>

Native transaction API. Propagates from underlying adapter if available.

Returns

Function

Parameters
ParameterType
fn(tx) => Promise<void>
Returns

Promise<void>

Inherited from

AdapterWrapper.transaction

Methods

capabilities()?

optional capabilities(): Partial<AdapterCapabilitiesReport>

Extended capabilities. Propagates from underlying adapter if available.

Returns

Partial<AdapterCapabilitiesReport>

Inherited from

AdapterWrapper.capabilities


clear()

clear(): Promise<void>

Clear all data.

Returns

Promise<void>

Overrides

AdapterWrapper.clear


delete()

delete(key): Promise<boolean>

Delete a key. Returns true if the key existed and was deleted.

Parameters

ParameterType
keyK

Returns

Promise<boolean>

Overrides

AdapterWrapper.delete


get()

get(key): Promise<V>

Get a value by key. Returns undefined if the key does not exist.

Parameters

ParameterType
keyK

Returns

Promise<V>

Overrides

AdapterWrapper.get


getCacheSize()

getCacheSize(): number

Get current cache size.

Returns

number


getConfig()

getConfig(): {
  maxAge: number;
  maxSize: number;
}

Get the current cache configuration.

Returns

{
  maxAge: number;
  maxSize: number;
}
NameType
maxAgenumber
maxSizenumber

getInnermostAdapter()

protected getInnermostAdapter(): FlashcoreAdapter<K, V>

Get the innermost adapter by unwrapping all wrappers.

Returns

FlashcoreAdapter<K, V>

Inherited from

AdapterWrapper.getInnermostAdapter


getStats()

getStats(): CacheStats

Get cache statistics.

Returns

CacheStats


getWrappedAdapter()

protected getWrappedAdapter(): FlashcoreAdapter<K, V>

Get the underlying (wrapped) adapter.

Returns

FlashcoreAdapter<K, V>

Inherited from

AdapterWrapper.getWrappedAdapter


has()

has(key): Promise<boolean>

Check if a key exists. Must return true for stored falsy values (0, false, '', null).

Parameters

ParameterType
keyK

Returns

Promise<boolean>

Overrides

AdapterWrapper.has


init()?

optional init(): void | Promise<void>

Initialize the adapter (e.g., connect, create directories). Called once during Flashcore.$.init().

Returns

void | Promise<void>

Inherited from

AdapterWrapper.init


invalidate()

invalidate(key): void

Invalidate a specific cache entry.

Parameters

ParameterType
keyK

Returns

void


invalidatePrefix()

invalidatePrefix(prefix): void

Invalidate all cache entries with a given prefix.

Parameters

ParameterType
prefixstring

Returns

void


prune()

prune(): number

Prune expired entries from the cache.

Returns

number


resetStats()

resetStats(): void

Reset cache statistics.

Returns

void


set()

set(key, value): Promise<boolean>

Set a key-value pair. Returns true if the operation succeeded.

Parameters

ParameterType
keyK
valueV

Returns

Promise<boolean>

Overrides

AdapterWrapper.set


shutdown()?

optional shutdown(): void | Promise<void>

Shutdown the adapter (e.g., close connections).

Returns

void | Promise<void>

Inherited from

AdapterWrapper.shutdown

On this page