Skip to content

Commit b55f2a8

Browse files
committed
enterprise-1.4.2
1 parent b7551b5 commit b55f2a8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

guides/object_cache/runtime_considerations.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ pp result.context[:object_cache]
5757
uncacheable: true, # if ObjectCache found a reason that this query couldn't be cached (see `messages: ...` for reason)
5858
}
5959
```
60+
61+
## Manually refreshing the cache
62+
63+
If you need to manually clear the cache for a query, pass `context: { refresh_object_cache: true, ... }`. This will cause the `ObjectCache` to remove the already-cached result (if there was one), reassess the query for cache validity, and return a freshly-executed result.
64+
65+
Usually, this shouldn't be necessary; making sure objects update their {% internal_link "cache fingerprints", "/object_cache/schema_setup.html#object-fingerprint" %} will cause entries to expire when they should be re-executed. See also {% internal_link "Schema fingerprint", "/object_cache/schema_setup.html#schema-fingerprint %} for expiring _all_ results in the cache.

guides/object_cache/schema_setup.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,17 @@ The returned strings are used as cache keys in the database -- whenever they cha
8484
- `def self.resolve_type(abstract_type, object, context)` which returns a GraphQL object type definition to use for `object`
8585

8686
After your schema is setup, you can {% internal_link "configure caching on your types and fields", "/object_cache/caching", %}.
87+
88+
## Schema Fingerprint
89+
90+
`ObjectCache` will also call `.fingerprint` on your Schema class. You can implement this method to return a new string if you make breaking changes to your schema, for example:
91+
92+
```ruby
93+
class MySchema < GraphQL::Schema
94+
def self.fingerprint
95+
"v2" # increment this if there are breaking changes to the schema
96+
end
97+
end
98+
```
99+
100+
By returning a new `MySchema.fingerprint`, _all_ previously-cached results will be expired.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cce6aca47058577462d4bf51c02b578c6aaf7bb47335e3435129efc9662e37e13756542d40ce728702a373d4e93416bb72202dfa9781bcc3de61c81b29471a5a

0 commit comments

Comments
 (0)