@envelop/parser-cache
Version:
This plugins adds simple LRU caching to your `parse`, to improve performance by caching the parsed result.
43 lines (30 loc) • 956 B
Markdown
This plugins adds simple LRU caching to your `parse`, to improve performance by caching the parsed result.
This plugins improves performance of parsing by ~60% (based on benchmarks).
```
yarn add @envelop/parser-cache
```
```ts
import { parse, validate, execute, subscribe } from 'graphql'
import { envelop } from '@envelop/core'
import { useParserCache } from '@envelop/parser-cache'
const getEnveloped = envelop({
parse,
validate,
execute,
subscribe,
plugins: [
// ... other plugins ...
useParserCache({
// options goes here
})
]
})
```
Set this to pass in a cache instance for caching documents. By default a new LRU cache is created using default `max` and `ttl`.
Set this to pass in a cache instance for caching errors. By default a new LRU cache is created using default `max` and `ttl`.