mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 02:01:40 -05:00
![]() This PR contains the following updates: | Package | Type | Update | Change | References | |---|---|---|---|---| | lru-cache | dependencies | major | `^4.1.3` -> `^5.0.0` | [source](https://renovatebot.com/gh/isaacs/node-lru-cache) | --- ### Release Notes <details> <summary>isaacs/node-lru-cache</summary> ### [`v5.1.1`](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v5.1.0...v5.1.1) [Compare Source](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v5.1.0...v5.1.1) ### [`v5.1.0`](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v5.0.1...v5.1.0) [Compare Source](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v5.0.1...v5.1.0) ### [`v5.0.1`](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v5.0.0...v5.0.1) [Compare Source](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v5.0.0...v5.0.1) ### [`v5.0.0`](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v4.1.4...v5.0.0) [Compare Source](https://renovatebot.com/gh/isaacs/node-lru-cache/compare/v4.1.4...v5.0.0) </details> --- ### Renovate configuration 📅 **Schedule**: "after 6pm every weekday,before 5am every weekday" in timezone America/Los_Angeles. 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻️ **Rebasing**: Whenever PR is stale, or if you modify the PR title to begin with "`rebase!`". 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- This PR has been generated by [Renovate Bot](https://renovatebot.com/gh/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#apollographql/apollo-server). |
||
---|---|---|
.. | ||
src | ||
.gitignore | ||
.npmignore | ||
jest.config.js | ||
package.json | ||
README.md | ||
tsconfig.json |
apollo-server-caching
Implementing your own Cache
Internally, Apollo Server uses the KeyValueCache
interface to provide a caching store for the Data Sources. An in-memory LRU cache is used by default, and we provide connectors for Memcached/Redis backends.
Built with extensibility in mind, you can also implement your own cache to use with Apollo Server, in a way that best suits your application needs. It needs to implement the following interface that can be exported from apollo-server-caching
:
export interface KeyValueCache {
get(key: string): Promise<string | undefined>;
set(key: string, value: string, options?: { ttl?: number }): Promise<void>;
}
Running test suite
You can export and run a jest test suite from apollo-server-caching
to test your implementation:
// ../__tests__/YourKeyValueCache.test.ts
import YourKeyValueCache from '../src/YourKeyValueCache';
import { testKeyValueCache } from 'apollo-server-caching';
testKeyValueCache(new MemcachedCache('localhost'));
Run tests with jest --verbose