Skip to content

Commit

Permalink
docs: improve managed ttl documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateu Aguiló Bosch committed Jul 23, 2018
1 parent 020ea6d commit 8613aa8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"bio": "Engineer and programmer focused on online applications.",
"public_repos": 67,
"public_gists": 35,
"followers": 83,
"followers": 86,
"following": 45,
"created_at": "2011-10-20T14:27:43Z",
"updated_at": "2018-05-31T14:20:57Z"
"updated_at": "2018-06-22T10:20:03Z"
}
]
16 changes: 16 additions & 0 deletions .emdaer/docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,30 @@ module. This is one of the [best performing libraries for LRU storages](https://
Create your Keyv object by executing:

```js
const { KeyvLru, KeyvLruManagedTtl } = require('keyv-lru');

const options = {
max: 1000,
notify: false,
ttl: 0,
expire: 0,
};
const keyvLru = new KeyvLru(options);
const keyvLruManagedTtl = new KeyvLruManagedTtl(options);
```

See [`tiny-lru`](https://www.npmjs.com/package/tiny-lru) to learn about the
available options.

## Managed TTLs
KeyvLruManagedTtl uses a managed TTL strategy instead of timers. This is useful
for serverless architectures. tiny-lru expires entries based on timers, that
means that the event loop is not empty when the lambda function is finished.
That blocks the end of the execution.

This implementation will store the expiration time along with the cached data
and it will deleter expired items upon retrieval. Alternatively there is an
`evictExpired()` method that will evict all the expired items.

Even when not using `tiny-lru`'s built-in expiration system based on timers, we
still benefit a lot from the LRU store.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
-->

<!--
emdaerHash:822f0a91a03b2ad9ab26ea6b2767fa06
emdaerHash:3ea3f30b6525f024e106916e59129a74
-->

<h1 id="keyv-lru-img-align-right-src-logo-svg-alt-keyv-logo-title-keyv-logo-width-100-">Keyv - LRU <img align="right" src="./logo.svg" alt="Keyv logo" title="Keyv logo" width="100"></h1>
Expand All @@ -18,6 +18,7 @@
</li>
<li><a href="#features">Features</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#managed-ttls">Managed TTLs</a></li>
<li><a href="#contributors">Contributors</a></li>
<li><a href="#license">License</a></li>
</ul>
Expand All @@ -37,16 +38,29 @@ module. This is one of the <a href="https://github.com/dominictarr/bench-lru#res
<p>Create your Keyv object by executing:</p>

```js
const { KeyvLru, KeyvLruManagedTtl } = require('keyv-lru');

const options = {
max: 1000,
notify: false,
ttl: 0,
expire: 0,
};
const keyvLru = new KeyvLru(options);
const keyvLruManagedTtl = new KeyvLruManagedTtl(options);
```
<p>See <a href="https://www.npmjs.com/package/tiny-lru"><code>tiny-lru</code></a> to learn about the
available options.</p>
<h2 id="managed-ttls">Managed TTLs</h2>
<p>KeyvLruManagedTtl uses a managed TTL strategy instead of timers. This is useful
for serverless architectures. tiny-lru expires entries based on timers, that
means that the event loop is not empty when the lambda function is finished.
That blocks the end of the execution.</p>
<p>This implementation will store the expiration time along with the cached data
and it will deleter expired items upon retrieval. Alternatively there is an
<code>evictExpired()</code> method that will evict all the expired items.</p>
<p>Even when not using <code>tiny-lru</code>‘s built-in expiration system based on timers, we
still benefit a lot from the LRU store.</p>
<h2 id="contributors">Contributors</h2>
<details>
<summary><strong>Contributors</strong></summary><br>
Expand Down

0 comments on commit 8613aa8

Please sign in to comment.