<commit_before># refreshable-cache

[![Build Status](https://travis-ci.org/jwngr/refreshable-cache.svg?branch=master)](https://travis-ci.org/jwngr/refreshable-cache)
[![GitHub version](https://badge.fury.io/gh/jwngr%2Frefreshable-cache.svg)](http://badge.fury.io/gh/jwngr%2Frefreshable-cache)

An in-memory, refreshable cache for Node.js. This cache has the following features:
* Optional time-based expiry on a per-item basis.
* Optional refresh intervals which allow you to update a cache item's value without resetting its
expiration time.
* Optional resetting of expiry whenever a cache item is accessed.


## Installation and Usage

The `refreshable-cache` module is available via `npm`:

```bash
$ npm install refreshable-cache --save
```

Once installed, a new cache can be created in your Node.js application as follows:

```js
var RefreshableCache = require('refreshable-cache');
var cache = new RefreshableCache();
```


## API Reference

### Methods

`put(key, value[, duration, refreshInterval])`

`get(key)`

`del(key)`

`clear()`

`on(eventName, callback)`

`resetExpiryOnAccess([shouldResetExpiry = true])`

`size()`

`keys()`


### `put(key, value[, duration, refreshInterval])`

**Arguments**

| Name | Type | Description |
| ---- | ---- | ----------- |
| `key` | `*` | The key whose value to write. |<commit_msg>Made API method overview section linkable in README<commit_after># refreshable-cache

[![Build Status](https://travis-ci.org/jwngr/refreshable-cache.svg?branch=master)](https://travis-ci.org/jwngr/refreshable-cache)
[![GitHub version](https://badge.fury.io/gh/jwngr%2Frefreshable-cache.svg)](http://badge.fury.io/gh/jwngr%2Frefreshable-cache)

An in-memory, refreshable cache for Node.js. This cache has the following features:
* Optional time-based expiry on a per-item basis.
* Optional refresh intervals which allow you to update a cache item's value without resetting its
expiration time.
* Optional resetting of expiry whenever a cache item is accessed.


## Installation and Usage

The `refreshable-cache` module is available via `npm`:

```bash
$ npm install refreshable-cache --save
```

Once installed, a new cache can be created in your Node.js application as follows:

```js
var RefreshableCache = require('refreshable-cache');
var cache = new RefreshableCache();
```


## API Reference

### Methods

[`put(key, value[, duration, refreshInterval])`](#putkey-value-duration-refreshinterval)

[`get(key)`](#getkey)

[`del(key)`](#delkey)

[`clear()`](#clear)

[`on(eventName, callback)`](#oneventname-callback)

[`resetExpiryOnAccess([shouldResetExpiry = true])`](#resetexpiryonaccessshouldresetexpiry--true)

[`size()`](#size)

[`keys()`](#keys)


### `put(key, value[, duration, refreshInterval])`

**Arguments**

| Name | Type | Description |
| ---- | ---- | ----------- |
| `key` | `*` | The key whose value to write. |
{'fraction_non_alphanumeric': 0.1642208245981831, 'fraction_numerical': 0.001397624039133473, 'mean_word_length': 4.890946502057613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3151485', 'n_tokens_mistral': 983, 'n_tokens_neox': 915, 'n_words': 247}