memcache-client-memoizer
Advanced tools
Comparing version 2.0.0 to 2.1.0
export declare type InputFunction = (...args: any[]) => Promise<any>; | ||
export interface ICacheClient { | ||
get(key: string): Promise<any>; | ||
set(key: string, value?: any, options?: any): any; | ||
get(key: any): Promise<any>; | ||
set(key: any, value?: any, options?: any): any; | ||
} | ||
@@ -6,0 +6,0 @@ export declare type ICacheClientProvider = () => ICacheClient; |
export type InputFunction = (...args: any[]) => Promise<any>; | ||
export interface ICacheClient { | ||
get(key: string): Promise<any>; | ||
get(key: any): Promise<any>; | ||
set(key: string, value?: any, options?: any): any; | ||
set(key: any, value?: any, options?: any): any; | ||
} | ||
@@ -8,0 +8,0 @@ |
{ | ||
"name": "memcache-client-memoizer", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Memoizes promise-returning functions via memcache-client", | ||
@@ -5,0 +5,0 @@ "main": "dist/index", |
@@ -23,3 +23,3 @@ ## memcache-client-memoizer | ||
* `options`: `object`. Required. An object with the following keys: | ||
* `client`: `{ get: (string) => Promise, set: (string, any) }`. A cache client instance, must have a `get` and `set` | ||
* `client`: `{ get: (anything) => Promise, set: (anything, value, options) }`. A cache client instance, must have a `get` and `set` | ||
method. The `get` method must return a promise. | ||
@@ -29,6 +29,6 @@ * `clientProviderFn`: `() => client` A function which returns a `client` (defined above); | ||
* `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 | ||
* `keyFn`: `(args to fn) => anything`. Required. A function which returns a cache-key (can be anything) for caching. 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}` | ||
const exampleKeyFn = ({ name, color }) => `${name}:${color}` // can be anything | ||
``` | ||
@@ -53,3 +53,3 @@ * `setOptions`: `object`. Optional. For `memcached-client` this can be | ||
fn: fnToMemoize, | ||
keyFn: ({ name, color }) => `${name}:${color}`, | ||
keyFn: ({ name, color }) => `${name}:${color}`, // this can return anything | ||
cacheResultTransformFn: ({value}) => value | ||
@@ -56,0 +56,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125168