Skip to content

Commit a5e12e8

Browse files
committed
enterprise-1.5.1
1 parent a7ecad1 commit a5e12e8

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

CHANGELOG-enterprise.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
### Bug Fix
1010

11+
# 1.5.1 (30 Aug 2024)
12+
13+
- ObjectCache: Add `connection_pool:` support
14+
1115
# 1.5.0 (26 Jul 2024)
1216

1317
- ObjectCache: Add Dalli backend for Memcached

guides/object_cache/redis.md

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,6 @@ index: 3
1111

1212
`GraphQL::Enterprise::ObjectCache` requires a Redis connection to store cached responses. Unlike `OperationStore` or rate limiters, this Redis instance should be configured to evict keys as needed.
1313

14-
## Data Structure
15-
16-
Under the hood, `ObjectCache` stores a mapping of queries and objects. Additionally, there are back-references from objects to queries that reference them. In general, like this:
17-
18-
```
19-
"query1:result" => '{"data":{...}}'
20-
"query1:objects" => ["obj1:v1", "obj2:v2"]
21-
22-
"query2:result" => '{"data":{...}}'
23-
"query2:objects" => ["obj2:v2", "obj3:v1"]
24-
25-
"obj1:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." }
26-
"obj2:v2" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." }
27-
"obj3:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." }
28-
29-
"obj1:v1:queries" => ["query1"]
30-
"obj2:v2:queries" => ["query1", "query2"]
31-
"obj3:v1:queries" => ["query2"]
32-
```
33-
34-
These mappings enable proper clean-up when queries or objects are expired from the cache. Additionally, whenever `ObjectCache` finds incomplete data in storage (for example, a necessary key was evicted), then it invalidates the whole query and re-runs it.
35-
3614
## Memory Management
3715

3816
Memory consumption is hard to estimate since it depends on how many queries the cache receives, how many objects those queries reference, how big the response is for those queries, and how long the fingerprints are for each object and query. To manage memory, configure the Redis instance with a `maxmemory` and `maxmemory-policy` directive, for example:
@@ -54,3 +32,33 @@ use GraphQL::Enterprise::ObjectCache, redis_cluster: Redis::Cluster.new(...)
5432
```
5533

5634
Under the hood, it uses query fingerprints as [hash tags](https://redis.io/docs/latest/operate/oss_and_stack/reference/cluster-spec/#hash-tags) and each cached result has its own set of object metadata.
35+
36+
## Connection Pool
37+
38+
`ObjectCache` also supports [ConnectionPool](https://github.com/mperham/connection_pool). To use it, pass `connection_pool:`:
39+
40+
```ruby
41+
use GraphQL::Enterprise::ObjectCache, connection_pool: ConnectionPool.new(...) { ... }
42+
```
43+
44+
## Data Structure
45+
46+
Under the hood, `ObjectCache` stores a mapping of queries and objects. Additionally, there are back-references from objects to queries that reference them. In general, like this:
47+
48+
```
49+
"query1:result" => '{"data":{...}}'
50+
"query1:objects" => ["obj1:v1", "obj2:v2"]
51+
52+
"query2:result" => '{"data":{...}}'
53+
"query2:objects" => ["obj2:v2", "obj3:v1"]
54+
55+
"obj1:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." }
56+
"obj2:v2" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." }
57+
"obj3:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." }
58+
59+
"obj1:v1:queries" => ["query1"]
60+
"obj2:v2:queries" => ["query1", "query2"]
61+
"obj3:v1:queries" => ["query2"]
62+
```
63+
64+
These mappings enable proper clean-up when queries or objects are expired from the cache. Additionally, whenever `ObjectCache` finds incomplete data in storage (for example, a necessary key was evicted), then it invalidates the whole query and re-runs it.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f83113767fb51f584f0d27b34f44fccc8ca05fab61e150bd6dd9098c9b3aef41751c4337ca994e2b78486fdd71c623a6d24da985d3bcee983a33c7a798a25e2d

0 commit comments

Comments
 (0)