Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update redis connection docs to match latest Keyv API #7944

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions docs/source/performance/cache-backends.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ npm install keyv @keyv/redis @apollo/utils.keyvadapter
### Single instance
```ts
import Keyv from "keyv";
import KeyvRedis from "@keyv/redis";
import { KeyvAdapter } from "@apollo/utils.keyvadapter";

const server = new ApolloServer({
typeDefs,
resolvers,
cache: new KeyvAdapter(new Keyv("redis://user:pass@localhost:6379")), // highlight-line
cache: new KeyvAdapter(new Keyv(new KeyvRedis("redis://user:pass@localhost:6379"))), // highlight-line
});
```

Expand All @@ -114,14 +115,14 @@ const server = new ApolloServer({
typeDefs,
resolvers,
// highlight-start
cache: new KeyvAdapter(
new Keyv("redis://user:pass@localhost:6379", {
cache: new KeyvAdapter(new Keyv(
new KeyvRedis("redis://user:pass@localhost:6379", {
sentinels: [
{ host: "localhost", port: 26379 },
{ host: "localhost", port: 26380 },
],
})
),
)),
// highlight-end
});
```
Expand Down Expand Up @@ -208,10 +209,11 @@ To provide error tolerance for cache backends that connect via a client (e.g., R

```typescript
import Keyv from "keyv";
import KeyvRedis from "@keyv/redis";
import { KeyvAdapter } from "@apollo/utils.keyvadapter";
import { ErrorsAreMissesCache } from "@apollo/utils.keyvaluecache";

const redisCache = new Keyv("redis://user:pass@localhost:6379");
const redisCache = new Keyv(new KeyvRedis("redis://user:pass@localhost:6379"));
const faultTolerantCache = new ErrorsAreMissesCache(
new KeyvAdapter(redisCache),
);
Expand Down