@aliwa/mapcache

Simple in map cache.

Usage no npm install needed!

<script type="module">
  import aliwaMapcache from 'https://cdn.skypack.dev/@aliwa/mapcache';
</script>

README

使用方法

安装

npm i @aliwa/MapCache 

以下两种用法注意 async/await 的使用。

仅「缓存到内存」

const mapStore = await MapCache.store( storeName );

mapStore.has( key );
mapStore.get( key );
mapStore.set( key, value, expires ); // expires unit: ms
mapStore.delete( key );
mapStore.clear();

「缓存到内存」并「持久化到文件」

const mapStore = await MapCache.store( storeName, jsonFilePath );

mapStore.has( key );
mapStore.get( key );
await mapStore.set( key, value, expires ); // expires unit: ms
await mapStore.delete( key );
await mapStore.clear();