Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

memcache-client-memoizer

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memcache-client-memoizer - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

2

package.json
{
"name": "memcache-client-memoizer",
"version": "2.1.0",
"version": "2.1.1",
"description": "Memoizes promise-returning functions via memcache-client",

@@ -5,0 +5,0 @@ "main": "dist/index",

## memcache-client-memoizer
A function memoizer using a get/set cache client like [memcache-client](https://www.npmjs.com/package/memcache-client).
A function memoizer using a get/set cache client.

@@ -33,3 +33,3 @@ [![travis][travis-image]][travis-url]

```
* `setOptions`: `object`. Optional. For `memcached-client` this can be
* `setOptions`: `anything`. Optional. For `memcached-client` this can be
[command options](https://www.npmjs.com/package/memcache-client#command-options).

@@ -42,3 +42,3 @@ * `cacheResultTransformFn`. `(result-from-cache) => transformed-result`. Function to transform cache-result, defaults

### memcache-client example:
### [memcache-client](https://www.npmjs.com/package/memcache-client) example:
```javascript

@@ -64,1 +64,28 @@ const MemcacheClient = require('memcache-client')

```
### [catbox](https://www.npmjs.com/package/catbox) example:
```javascript
const Catbox = require('catbox');
const Memory = require('catbox-memory');
const cacheTtlMilliseconds = 1000 * 60 * 5; // 5 min
const client = new Catbox.Client(Memory);
await client.start();
const fnToMemoize = ({ name, color }) => Promise.resolve({ name, color })
const memoizedFn = memoizer({
client,
fn: fnToMemoize,
keyFn: ({ name, color }) => ({ segment: 'test', id: 'test-cache' }), // this can return anything
setOptions: cacheTtlMilliseconds,
cacheResultTransformFn: ({ item }) => item,
})
memoizedFn({name: 'Max', color: 'blue'})
.then((result) => { ... }) // cache miss, fill cache, returns {name: 'Max', color: 'blue'}
// later on...
memoizedFn({name: 'Max', color: 'blue'})
.then((result) => { ... }) // cache hit, returns {name: 'Max', color: 'blue'}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc