{"_id":"@dfrechette/apollo-server-caching","_rev":"1-cc9a5e42d70a753aa2435214e0a24714","name":"@dfrechette/apollo-server-caching","dist-tags":{"latest":"0.5.2"},"versions":{"0.5.2":{"name":"@dfrechette/apollo-server-caching","version":"0.5.2","author":{"name":"Apollo","email":"opensource@apollographql.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/davidfrechette/apollo-server.git","directory":"packages/apollo-server-caching"},"homepage":"https://github.com/davidfrechette/apollo-server#readme","bugs":{"url":"https://github.com/davidfrechette/apollo-server/issues"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=6"},"dependencies":{"lru-cache":"^5.0.0"},"description":"[![npm version](https://badge.fury.io/js/apollo-server-caching.svg)](https://badge.fury.io/js/apollo-server-caching) [![Build Status](https://circleci.com/gh/apollographql/apollo-server/tree/main.svg?style=svg)](https://circleci.com/gh/apollographql/apoll","_id":"@dfrechette/apollo-server-caching@0.5.2","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-KB4LOrFlgxCY6gzD8uSq4Hbv6ZT4tgaL85FYlJYDDNF6ymxEkzWqwIaHx7f8UZvyc//jCSfBDzBfHD92xFdv2A==","shasum":"ee20ba90d004b33b9c039a51e358b1786fa55b85","tarball":"https://registry.npmjs.org/@dfrechette/apollo-server-caching/-/apollo-server-caching-0.5.2.tgz","fileCount":26,"unpackedSize":19737,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfb7MKCRA9TVsSAnZWagAA4LcP+QCrqeBv5x3Lo+FLl8rs\n1Xr1pfP3+TXgWunizQrtGn0FBAeGN/FymD4hnCPF+8Y5mU8Zcta75zq5dU+k\n7NtvXyXoBLdpJHoP6AysO7z3L7zssCAvUDMJGNEom7cyKWENl4lXxIOCeyTu\n/E75CHW9QBNdtgWCeJRswy+7fbEbik7fchbv+35e+j04GGF/zI5npI4FNWTz\nDE9kdOb7AqR/ZryyJkmOci+UcPcziXQ5HJHB3p3JzOt6KzqQfxp4lFOAUqIK\n1/7xqxPagEDVzSZboo945umOPOqZo/ZXd5gJVjntR29H1k+Ph+q3PWScTa23\nFedRXe183cPQzjm9xXPhfvB+QcLJBkqEQqU+4eipQ+Rtq/Y8U5Fus7ua9mmj\n39SnutqUoVNCPO22zgRcNLO3d/lx1fQr+Gsk0wbxdqBGfantWn+hN6GhIOWy\nRmrgCVGL2tdWLz09Y+GJBDGTuHFvhHALM+8COanvS8F1166KFAaCyrJlYk3V\nyiGI/Vu/MS41ld0ptqwvpSJ5cgryeDU9iS5AjKkf8lDShPQq1aAScYCeQjmg\ncd0fipTViDlH5kHShR0xs7O1GvqSaoBJljUDU92Hg/VRgjPzzPG19p3N3kvG\npAsnTquVjiCQFlcKK0X+mzEUdNCqyikgsMHRy8ZOorM8fY460l4WJIQCkkDA\nw9ov\r\n=30Ly\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICRFkOfRFvE7JgPboy0F4d/sdoClEc96pqJlTj9zh7/eAiBqwHDovjskmYmZXJZ8Nun0qEabfW9S0wP9kTZjR0F54Q=="}]},"maintainers":[{"name":"dfrechette","email":"david.frechette@cossette.com"}],"_npmUser":{"name":"dfrechette","email":"david.frechette@cossette.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apollo-server-caching_0.5.2_1601155850121_0.036692476340200786"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-26T21:30:50.079Z","0.5.2":"2020-09-26T21:30:50.244Z","modified":"2022-04-05T04:17:47.352Z"},"maintainers":[{"name":"dfrechette","email":"david.frechette@cossette.com"}],"description":"[![npm version](https://badge.fury.io/js/apollo-server-caching.svg)](https://badge.fury.io/js/apollo-server-caching) [![Build Status](https://circleci.com/gh/apollographql/apollo-server/tree/main.svg?style=svg)](https://circleci.com/gh/apollographql/apoll","homepage":"https://github.com/davidfrechette/apollo-server#readme","repository":{"type":"git","url":"git+https://github.com/davidfrechette/apollo-server.git","directory":"packages/apollo-server-caching"},"author":{"name":"Apollo","email":"opensource@apollographql.com"},"bugs":{"url":"https://github.com/davidfrechette/apollo-server/issues"},"license":"MIT","readme":"# apollo-server-caching\n\n[![npm version](https://badge.fury.io/js/apollo-server-caching.svg)](https://badge.fury.io/js/apollo-server-caching)\n[![Build Status](https://circleci.com/gh/apollographql/apollo-server/tree/main.svg?style=svg)](https://circleci.com/gh/apollographql/apollo-server)\n\n## Implementing your own Cache\n\nInternally, 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](../apollo-server-cache-memcached)/[Redis](../apollo-server-cache-redis) backends.\n\nBuilt 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`:\n\n```typescript\nexport interface KeyValueCache {\n  get(key: string): Promise<string | undefined>;\n  set(key: string, value: string, options?: { ttl?: number }): Promise<void>;\n}\n```\n\n> The `ttl` value for the `set` method's `options` is specified in __seconds__.\n\n## Testing cache implementations\n\n### Test helpers\n\nYou can export and run a jest test suite from `apollo-server-caching` to test your implementation:\n\n```typescript\n// ../__tests__/YourKeyValueCache.test.ts\n\nimport YourKeyValueCache from '../src/YourKeyValueCache';\nimport { testKeyValueCache } from 'apollo-server-caching';\ntestKeyValueCache(new MemcachedCache('localhost'));\n```\n\nThe default `testKeyValueCache` helper will run all key-value store tests on the specified store, including basic `get` and `set` functionality, along with time-based expunging rules.\n\nSome key-value cache implementations may not be able to support the full suite of tests (for example, some tests might not be able to expire based on time).  For those cases, there are more granular implementations which can be used:\n\n* `testKeyValueCache_Basic`\n* `testKeyValueCache_Expiration`\n\nFor more details, consult the [source for `apollo-server-caching`](./src/__tests__/testsuite.ts).\n\n### Running tests\n\nRun tests with `jest --verbose`\n","readmeFilename":"README.md"}