Immediately store the content as cache with the specified key (with optional overwriting default ttl set on the cache constructor).
```javascript
cache.setSync('mykey', { hello: 'world' }, 5 * 60) // Expire this after 5 minutes
```
### cache.setMany(items, ttl | { ttl: number } = null)
### cache.save(items, ttl | { ttl: number } = null)
Promise store multiple items all at once while optionally overwriting the ttl for these entries.
Items take form of an array of json objects with the following signature: `{ key, content }`
**Note**, for backwards compatibility with `file-system-cache` you can also use the property `value` instead of `content`.
```javascript
await cache.setMany([
{ key: 'one', content: 'Store this' },
{ key: 'two', content: { a: 'and also this' } },
])
await cache.save([
{ key: 'one', value: 'Store this' },
{ key: 'two', value: { a: 'and also this' } },
])
```
### cache.setManySync(items, ttl | { ttl: number } = null)
### cache.saveSync(items, ttl | { ttl: number } = null)
Immediately store multiple items all at once while optionally overwriting the ttl for these entries.
Items take form of an array of json objects with the following signature: `{ key, content }`
**Note**, for backwards compatibility with `file-system-cache` you can also use the property `value` instead of `content`.
**Note**, there's an alternative name for it called `.saveSync(...)` for retaining similar naming schema as `file-system-cache` (it does not provide this functionality).
```javascript
cache.setManySync([
{ key: 'one', content: 'Store this' },
{ key: 'two', content: { a: 'and also this' } },
], 10 * 60) // Expire all of these after 10 minutes.
cache.saveSync([
{ key: 'one', value: 'Store this' },
{ key: 'two', value: { a: 'and also this' } },
], 10 * 60) // Expire all of these after 10 minutes.
```
### cache.remove(key)
Promise remove a cache with the specified key.
```javascript
await cache.remove('mykey')
```
### cache.removeSync(key)
Immediately remove a cache with the specified key.
```javascript
cache.removeSync('mykey')
```
### cache.clear()
Promise remove all items in the cache directory that match the specified `prefix` or `ns` if you will.
```javascript
await cache.clear()
```
### cache.clearSync()
Immediately remove all items in the cache directory that match the specified `prefix` or `ns` if you will.
```javascript
cache.clearSync()
```
### cache.getAll()
Promise return all items currently residing in the cache that have valid ttl.
This returns an array of objects, each one with with following signature: `{ key, content, ttl }`