@envelop/response-cache-redis 1.0.0-alpha-9e9dfbb.0 → 1.0.0-alpha-e41b2ae.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +25 -27
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -22,12 +22,10 @@ In order to use the Redis cache, you need to:
22
22
  - Create an instance of the Redis Cache and set to the `useResponseCache` plugin options
23
23
 
24
24
  ```ts
25
-
26
- import { envelop } from '@envelop/core';
27
- import { useResponseCache } from '@envelop/response-cache';
28
- import { createRedisCache } from '@envelop/response-cache-redis';
29
-
30
- import Redis from 'ioredis';
25
+ import { envelop } from '@envelop/core'
26
+ import { useResponseCache } from '@envelop/response-cache'
27
+ import { createRedisCache } from '@envelop/response-cache-redis'
28
+ import Redis from 'ioredis'
31
29
 
32
30
  /**
33
31
  * For additional Redis options to create the ioredis client
@@ -37,35 +35,35 @@ import Redis from 'ioredis';
37
35
  const redis = new Redis({
38
36
  host: 'my-redis-db.example.com',
39
37
  port: '30652',
40
- password: '1234567890',
41
- });
38
+ password: '1234567890'
39
+ })
42
40
 
43
41
  // or, you can also specify connection options as a redis:// URL or rediss:// URL when using TLS encryption
44
- const redis = new Redis(("rediss://:1234567890@my-redis-db.example.com':30652");
42
+ const redis = new Redis('rediss://:1234567890@my-redis-db.example.com:30652')
45
43
 
46
- const cache = createRedisCache({ redis });
44
+ const cache = createRedisCache({ redis })
47
45
 
48
46
  const getEnveloped = envelop({
49
47
  plugins: [
50
48
  // ... other plugins ...
51
- useResponseCache({ cache }),
52
- ],
53
- });
49
+ useResponseCache({ cache })
50
+ ]
51
+ })
54
52
  ```
55
53
 
56
54
  ### Invalidate Cache based on custom logic
57
55
 
58
56
  ```ts
59
- import { envelop } from '@envelop/core';
60
- import { useResponseCache } from '@envelop/response-cache';
61
- import { createRedisCache } from '@envelop/response-cache-redis';
57
+ import { envelop } from '@envelop/core'
58
+ import { useResponseCache } from '@envelop/response-cache'
59
+ import { createRedisCache } from '@envelop/response-cache-redis'
62
60
 
63
- import { emitter } from './eventEmitter';
61
+ import { emitter } from './eventEmitter'
64
62
 
65
63
  // we create our cache instance, which allows calling all methods on it
66
- const redis = new Redis(("rediss://:1234567890@my-redis-db.example.com':30652");
64
+ const redis = new Redis('rediss://:1234567890@my-redis-db.example.com:30652')
67
65
 
68
- const cache = createRedisCache({ redis });
66
+ const cache = createRedisCache({ redis })
69
67
 
70
68
  const getEnveloped = envelop({
71
69
  plugins: [
@@ -73,17 +71,17 @@ const getEnveloped = envelop({
73
71
  useResponseCache({
74
72
  ttl: 2000,
75
73
  // we pass the cache instance to the request.
76
- cache,
77
- }),
78
- ],
79
- });
74
+ cache
75
+ })
76
+ ]
77
+ })
80
78
 
81
79
  emitter.on('invalidate', resource => {
82
80
  cache.invalidate([
83
81
  {
84
82
  typename: resource.type,
85
- id: resource.id,
86
- },
87
- ]);
88
- });
83
+ id: resource.id
84
+ }
85
+ ])
86
+ })
89
87
  ```
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/response-cache-redis",
3
- "version": "1.0.0-alpha-9e9dfbb.0",
3
+ "version": "1.0.0-alpha-e41b2ae.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {},
6
6
  "dependencies": {
7
- "@envelop/response-cache": "3.0.0-alpha-9e9dfbb.0",
7
+ "@envelop/response-cache": "3.0.0-alpha-e41b2ae.0",
8
8
  "ioredis": "^4.27.9"
9
9
  },
10
10
  "repository": {