@nulliel/nu-cache

A simple caching solution.

Usage no npm install needed!

<script type="module">
  import nullielNuCache from 'https://cdn.skypack.dev/@nulliel/nu-cache';
</script>

README

nu-cache

A simple caching solution.

npm (scoped) Build Status Codecov Dependency Status devDependency Status

Install

npm install @nulliel/nu-cache

Usage

const Store = require('@nulliel/nu-cache');
const Cache = require('@nulliel/nu-cache').cache;

const store = new Store();
const cache = new Cache();

store#createCache(cacheName)

Create a cache.

Throws if cache already exists.

Returns a cache object.

store#removeCache(cacheName)

Remove a cache.

Throws if cache does not exist.

store#getCache(cacheName)

Get a cache.

Throws if cache does not exist. Returns a cache object.

store#hasCache(cacheName)

Check if a cache exists.

Returns true/false.

cache#get(prop)

Get a property from the cache.

Returns a non mutable object (use merge or update to update values)

Can get nested values cache.get('prop.nested');

Throws if property does not exist.

cache#getAll()

Get all properties from the cache. Returns a non mutable object (use merge or update to update values)

cache#set(prop, value)

Set a property from the cache.

Throws if property already exists. Use update to update a value.

cache#merge(obj)

Merge an object into the cache.

cache#has(prop)

Check if cache has a property.

Returns true/false

cache#update(prop, value)

Update a property in the cache.

Throws if property does not exist.

cache#delete(prop)

Delete a property in the cache.

Throws if property does not exist.