From 8613aa8e9fee4dfef914dba37a280631e144b1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateu=20Aguil=C3=B3=20Bosch?= Date: Mon, 23 Jul 2018 12:48:37 +0200 Subject: [PATCH] docs: improve managed ttl documentation --- .../contributors-data.json | 4 ++-- .emdaer/docs/install.md | 16 ++++++++++++++++ README.md | 16 +++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.emdaer/.offline/plugin-contributors-details-github/contributors-data.json b/.emdaer/.offline/plugin-contributors-details-github/contributors-data.json index eae7f23..10cbf9f 100644 --- a/.emdaer/.offline/plugin-contributors-details-github/contributors-data.json +++ b/.emdaer/.offline/plugin-contributors-details-github/contributors-data.json @@ -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" } ] diff --git a/.emdaer/docs/install.md b/.emdaer/docs/install.md index fd38bc4..9cbc464 100644 --- a/.emdaer/docs/install.md +++ b/.emdaer/docs/install.md @@ -16,6 +16,8 @@ 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, @@ -23,7 +25,21 @@ const options = { 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. diff --git a/README.md b/README.md index a85a1c9..d504b1b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ -->

Keyv - LRU Keyv logo

@@ -18,6 +18,7 @@
  • Features
  • Usage
  • +
  • Managed TTLs
  • Contributors
  • License
  • @@ -37,6 +38,8 @@ module. This is one of the 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.

    Contributors

    Contributors