Skip to content

Commit

Permalink
feat: add @cache-discard-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Apr 25, 2023
1 parent 9973ea7 commit 8e99781
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ Which queries are cached is controlled using cache attributes. Cache attributes
|Cache attribute|Description|Required?|Format|Default|
|---|---|---|---|---|
|`@cache-ttl`|Number (in seconds) to cache the query for.|Yes|`/^d+$/`|N/A|
|`@cache-key`|Uniquelly identifies the query. Overrides the default cache key that uniquely identifies the query. If present, `$bodyHash` is substituted with the hash of the query (comments and white-spaces are stripped before hashing the query). `$valueHash` is substituted with the hash of the parameter values.|No|`/^[$A-Za-z0-9\-_:]+$/`|`$bodyHash:$valueHash`|
|`@cache-key`|Cache key that uniquelly identifies the query.|No|`/^[$A-Za-z0-9\-_:]+$/`|`$bodyHash:$valueHash`|
|`@cache-discard-empty`|If set to `true`, then `storage.set` is not invoked when query produces no results.|No|`/^(false|true)$/`|`false`|

### `@cache-key`

Overrides the default cache key that uniquely identifies the query.

If present, `$bodyHash` is substituted with the hash of the query (comments and white-spaces are stripped before hashing the query). `$valueHash` is substituted with the hash of the parameter values.

### Example usage

This example shows how to create a compatible storage service using [`node-cache`](https://www.npmjs.com/package/node-cache).
Expand Down

0 comments on commit 8e99781

Please sign in to comment.