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 0.0.4 to 1.0.0

dist/index.d.ts

40

package.json
{
"name": "memcache-client-memoizer",
"version": "0.0.4",
"version": "1.0.0",
"description": "Memoizes promise-returning functions via memcache-client",
"main": "index.js",
"main": "dist/index",
"typings": "dist/index",
"scripts": {
"pretest": "./node_modules/.bin/standard --verbose | ./node_modules/.bin/snazzy",
"test": "jest"
"build": "./node_modules/.bin/tsc",
"lint": "./node_modules/.bin/tslint --format stylish --project .",
"pretest": "npm run lint && npm run build",
"test": "jest",
"prepublishOnly": "npm test"
},

@@ -19,26 +23,16 @@ "homepage": "https://github.com/maxnachlinger/memcache-client-memoizer",

"engines": {
"node": "8.x.x"
"node": ">=8"
},
"author": "Max Nachlinger",
"license": "ISC",
"dependencies": {
"lodash.isfunction": "3.0.9"
},
"dependencies": {},
"devDependencies": {
"jest": "22.3.0",
"memcache-client": "0.10.0",
"snazzy": "7.0.0",
"standard": "10.0.3",
"uuid": "3.2.1"
},
"standard": {
"globals": [
"jest",
"beforeEach",
"afterEach",
"describe",
"it",
"expect"
]
"@types/jest": "^23.0.0",
"@types/uuid": "^3.4.3",
"jest": "^23.1.0",
"tslint": "^5.10.0",
"tslint-xo": "^0.8.0",
"typescript": "^2.9.1",
"uuid": "^3.2.1"
}
}
## memcache-client-memoizer
A function memoizer using [memcache-client](https://www.npmjs.com/package/memcache-client).
A function memoizer using a get/set cache client like [memcache-client](https://www.npmjs.com/package/memcache-client).

@@ -23,9 +23,16 @@ [![travis][travis-image]][travis-url]

* `options`: `object`. Required. An object with the following keys:
* `client`: `memcache-client instance`. Required. A [memcache-client](https://www.npmjs.com/package/memcache-client) instance.
* `client`: `{ get: (string) => Promise, set: (string, any) }`. A cache client instance, must have a `get` and `set`
method. The `get` method must return a promise.
* `clientProviderFn`: `() => client` A function which returns a `client` (defined above);
(Either a `client` or `clientProviderFn` must be passed.)
* `fn`: `Function`. Required. The function to memoize, must return a Promise.
* `keyFn`: `(args to fn) => 'key-string'`. Required. A function which returns a string cache-key for memcached. This function is called with the same arguments as `fn`, allowing you to create a dynamic cache-key, for example:
* `keyFn`: `(args to fn) => 'key-string'`. Required. A function which returns a string cache-key for memcached. This
function is called with the same arguments as `fn`, allowing you to create a dynamic cache-key, for example:
```javascript
const exampleKeyFn = ({ name, color }) => `${name}:${color}`
```
* `setOptions`: `object`. Optional. `memcached-client` [command options](https://www.npmjs.com/package/memcache-client#command-options).
* `setOptions`: `object`. Optional. For `memcached-client` this can be
[command options](https://www.npmjs.com/package/memcache-client#command-options).
* `cacheResultTransformFn`. `(result-from-cache) => transformed-result`. Function to transform cache-result, defaults
to `(x) => x`. This is useful if your cache service sends along the value in a different form than is returned by your `fn`.

@@ -35,3 +42,3 @@ ### Note:

### Example:
### memcache-client example:
```javascript

@@ -41,9 +48,9 @@ const MemcacheClient = require('memcache-client')

const client = new MemcacheClient({ server: 'localhost:11211' })
const fnToMemoize = ({ name, color }) => Promise.resolve({ name, color })
const memoizedFn = memoizer({
client,
clientProviderFn: () => new MemcacheClient({ server: 'localhost:11211' }),
fn: fnToMemoize,
keyFn: ({ name, color }) => `${name}:${color}`
keyFn: ({ name, color }) => `${name}:${color}`,
cacheResultTransformFn: ({value}) => value
})

@@ -50,0 +57,0 @@

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