diff --git a/CHANGELOG-enterprise.md b/CHANGELOG-enterprise.md index bb8b95123f..0051752a54 100644 --- a/CHANGELOG-enterprise.md +++ b/CHANGELOG-enterprise.md @@ -8,6 +8,10 @@ ### Bug Fix +# 1.5.1 (30 Aug 2024) + +- ObjectCache: Add `connection_pool:` support + # 1.5.0 (26 Jul 2024) - ObjectCache: Add Dalli backend for Memcached diff --git a/guides/object_cache/redis.md b/guides/object_cache/redis.md index 6f68145dae..9d352ed84a 100644 --- a/guides/object_cache/redis.md +++ b/guides/object_cache/redis.md @@ -11,28 +11,6 @@ index: 3 `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. -## Data Structure - -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: - -``` -"query1:result" => '{"data":{...}}' -"query1:objects" => ["obj1:v1", "obj2:v2"] - -"query2:result" => '{"data":{...}}' -"query2:objects" => ["obj2:v2", "obj3:v1"] - -"obj1:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." } -"obj2:v2" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." } -"obj3:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." } - -"obj1:v1:queries" => ["query1"] -"obj2:v2:queries" => ["query1", "query2"] -"obj3:v1:queries" => ["query2"] -``` - -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. - ## Memory Management 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(...) ``` 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. + +## Connection Pool + +`ObjectCache` also supports [ConnectionPool](https://github.com/mperham/connection_pool). To use it, pass `connection_pool:`: + +```ruby +use GraphQL::Enterprise::ObjectCache, connection_pool: ConnectionPool.new(...) { ... } +``` + +## Data Structure + +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: + +``` +"query1:result" => '{"data":{...}}' +"query1:objects" => ["obj1:v1", "obj2:v2"] + +"query2:result" => '{"data":{...}}' +"query2:objects" => ["obj2:v2", "obj3:v1"] + +"obj1:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." } +"obj2:v2" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." } +"obj3:v1" => { "fingerprint" => "...", "id" => "...", "type_name" => "..." } + +"obj1:v1:queries" => ["query1"] +"obj2:v2:queries" => ["query1", "query2"] +"obj3:v1:queries" => ["query2"] +``` + +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. diff --git a/guides/pro/checksums/graphql-enterprise-1.5.1.txt b/guides/pro/checksums/graphql-enterprise-1.5.1.txt new file mode 100644 index 0000000000..d56f308b5a --- /dev/null +++ b/guides/pro/checksums/graphql-enterprise-1.5.1.txt @@ -0,0 +1 @@ +f83113767fb51f584f0d27b34f44fccc8ca05fab61e150bd6dd9098c9b3aef41751c4337ca994e2b78486fdd71c623a6d24da985d3bcee983a33c7a798a25e2d