Cache Configurations
The following snippet shows the current available cache configurations options
type CacheSettings = { /** * Cache Settings */ cache?: { /** * The Cache drier interface, defaults to plainLocalStorage */ driver?: CacheDriverInterface; /** * A prefix for each key in the driver, this is useful for multi apps in same domain */ prefix?: string; }};
#
Configurations ListThe base cache config key is cache
so the following table keys wil be prefixed with cache.
for usage.
Syntax | Type | Default Value | Description | |
---|---|---|---|---|
key | String | `` | A prefix that will be appened to all cache keys, for example the prefix key is app- then when storing key name , it will be stored as app-name in the driver engine. | |
driver | Instance Of Cache Driver Interface | Plain Local Storage Driver | The default cache driver engine that will be used by the Cache Manager, full list of drivers are here. |
#
Example Of Usageshared/config.ts
import config, { ConfigList } from 'mongez/config';import { EncryptedLocalStorageDriver } from 'mongez/cache';
const settings: ConfigList = { cache: { prefix: 'mngz-', driver: new EncryptedLocalStorageDriver(), },};
config.set(settings);
The previous configurations will prefix all stored keys with mngz-
and the driver engine will be the Encrypted Local Storage.
It's advisable to use the
prefix
key to set it to beprocess.env.REACT_APP_KEY_NAME
suffixed with-
.
shared/config.ts
import config, { ConfigList } from 'mongez/config';import { EncryptedLocalStorageDriver } from 'mongez/cache';
const settings: ConfigList = { cache: { prefix: process.env.REACT_APP_KEY_NAME + '-', driver: new EncryptedLocalStorageDriver(), },};
config.set(settings);