BajoCache

BajoCache class definition.

This class is used to manage caching in the Bajo framework. It provides methods to set, get, clear, and remove cached items, as well as a method to synchronize cache with the underlying data source.

It supports caching for result sets, generic items, and function results, with configurable time-to-live (TTL) and expiration handling.

Constructor

new BajoCache()

Members

config :BajoCache.TConfig

Configuration object.

fnCache :Array

Array container for cached functions

Type:
  • Array

Methods

(async) clear(optsopt) → {Promise.<void>}

Clear cached items.

Parameters:
NameTypeAttributesDefaultDescription
optsObject<optional>
{}

Options for clearing cache

Returns:
Type: 
Promise.<void>

(async) get(optsopt) → {Promise.<any>}

Get cached items.

Parameters:
NameTypeAttributesDefaultDescription
optsObject<optional>
{}

Options for getting cache

Returns:
  • Returns the cached item or undefined if not found
Type: 
Promise.<any>

(async) remove(optsopt) → {Promise.<void>}

Remove cached items.

Parameters:
NameTypeAttributesDefaultDescription
optsObject<optional>
{}

Options for removing cache

Returns:
Type: 
Promise.<void>

(async) set(optsopt) → {Promise.<void>}

Set cached items.

Parameters:
NameTypeAttributesDefaultDescription
optsObject<optional>
{}

Options for setting cache

Returns:
Type: 
Promise.<void>

(async) start() → {Promise.<void>}

Start the plugin.

Returns:
Type: 
Promise.<void>

(async) sync(optsopt) → {Promise.<any>}

Sync cached items.

Parameters:
NameTypeAttributesDefaultDescription
optsObject<optional>
{}

Options for syncing cache

Returns:
  • Returns the cached item or the value set
Type: 
Promise.<any>

Type Definitions

TConfig

Configuration object.

To override the default configuration, you can create a bajo-cache.json file in your {dataDir}/config/bajoCache.json and set your custom configuration values there.

Type:
  • Object
Properties
NameTypeAttributesDefaultDescription
connectionstring<optional>
'memory'

Dobo connection to use. Default is 'memory'

defaultObject<optional>
{}

Default configuration for cache items

Properties
NameTypeAttributesDefaultDescription
ttlDurstring<optional>
'5s'

Default time-to-live duration for cache items. Default is '5s'

removeExpiredDurstring<optional>
'1s'

Duration for removing expired cache items. Default is '1s'

doboObject<optional>
{}

Configuration for the dobo store

exportPrefixstring<optional>
'~'

Prefix for exported cache keys. Default is '~'

waibuAdminObject<optional>
{}

Configuration for waibu admin

Properties
NameTypeAttributesDefaultDescription
menuHandlerboolean<optional>
false

Whether to enable menu handler in waibu admin. Default is false

modelDisabledstring<optional>
'*'

Model disabled setting in waibu admin. Default is '*'