graphql-result_cache 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/graphql/result_cache.rb +3 -0
- data/lib/graphql/result_cache/condition.rb +14 -6
- data/lib/graphql/result_cache/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e5a9de4f745ffd391664a5189555d9b4b156f33d7395f3e6bf9e13a4dc1473
|
4
|
+
data.tar.gz: b37e2c2ed1737f55b9b5485f315f49874451bed231eec0c8c26dd9b13cc77889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d22ade1c0db8835b52b4c676f13ebdb43c1072048b3b608f841334913a30c57ec4b7e62bad9497c672533b03481ec32b05444eb64835f9c85173ea82e9206f0
|
7
|
+
data.tar.gz: ff613c81a571657c2e57abf8e3b9dce83375548e94f4d938e024c6071058c64e8c5d3ef14ec416c2e1fc3ca3c4cf1669294563b0f6dedb8fe8b9390d2f78dd1e
|
data/README.md
CHANGED
@@ -105,6 +105,7 @@ GraphQL::ResultCache.configure do |config|
|
|
105
105
|
config.namespace = "GraphQL:Result" # Cache key namespace
|
106
106
|
config.expires_in = 1.hour # Expire time for the cache, default to 1.hour
|
107
107
|
config.client_hash = -> { Rails.cache.read(:deploy_version) } # GraphQL client package hash key, used in cache key generation, default to nil
|
108
|
+
config.except = ->(ctx) { !ctx[:result_cacheable] } # Exception rule, skip the cache while evaluated as true, default to nil
|
108
109
|
config.cache = Rails.cache # The cache object, default to Rails.cache in Rails
|
109
110
|
config.logger = Rails.logger # The Logger, default to Rails.logger in Rails
|
110
111
|
end
|
data/lib/graphql/result_cache.rb
CHANGED
@@ -18,6 +18,9 @@ module GraphQL
|
|
18
18
|
# c.client_hash = -> { Rails.cache.read(:deploy_version) }
|
19
19
|
attr_accessor :client_hash
|
20
20
|
|
21
|
+
# global condition, skip the cache when the value is true, should be a proc.
|
22
|
+
attr_accessor :except
|
23
|
+
|
21
24
|
# ```
|
22
25
|
# GraphQL::ResultCache.configure do |c|
|
23
26
|
# c.namespace = "GraphQL:Result"
|
@@ -9,15 +9,23 @@ module GraphQL
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def true?
|
12
|
+
return false if except?
|
12
13
|
case @if
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
when Symbol
|
15
|
+
@obj.send(@if)
|
16
|
+
when Proc
|
17
|
+
@if.call(@obj, @args, @ctx)
|
18
|
+
else
|
19
|
+
true
|
19
20
|
end
|
20
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def except?
|
26
|
+
except = ::GraphQL::ResultCache.except
|
27
|
+
except.is_a?(Proc) ? except.call(@ctx) : except
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-result_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ying Fu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|