graphql-fragment_cache 0.1.7 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c1bfd3dbaadd053ae1e47ac16d1cb244410adeae3424b30d58b04516447bfe6
4
- data.tar.gz: 10de0c52b16423e65db745433a61aef94c795edca3b4b47c3ef834f7118d0a5f
3
+ metadata.gz: 96ef4de68daa875700330eed182cbbfeffb9c4dfff34dafd3661fc3513e06fc6
4
+ data.tar.gz: f24010337c683b12498c8c1cd949bb4ba43cb97dae80d9f617b0694a78329fdf
5
5
  SHA512:
6
- metadata.gz: 54ad113a7ef913df0c283c130bae045621dd99298bb1e658e6a4e00440fa29a6ac3d39f45789b49f9cc8a09ddaf34fe4af18560ebbc1c41d73e33d6e539e9b10
7
- data.tar.gz: b36091bf683d1018e47ae0fcfd5e69fedad20d4a7b20687a67315d721efa63a5b5df158cb8142ed6342b5ae77c3bd41d08a281299d16f0fcd10d74107e5db78e
6
+ metadata.gz: b5d84c411a488bac34c2e0c2237c3dcc7b51e44bd60195560ba81a8ee2cab6fd8d888f8946a103225b5dd14dc3202da4167a09901ad89264dee0bb3b34633fbd
7
+ data.tar.gz: 03bfa7468e8199ca87d81bcd8839f9dab0a7c6b4764538757727ad20d641c30da380af9b55a5496ef7ab77dafd444b2a8a39bd44d983d6e8eb53c0c63821f88f
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.0 (2020-06-13)
6
+
7
+ - [PR#24](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/24) Add nil caching. **BREAKING CHANGE**: custom cache stores must also implement `#exist?(key)` method ([@DmitryTsepelev][])
8
+
5
9
  ## 0.1.7 (2020-06-02)
6
10
 
7
11
  - [PR#23](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/23) Avoid extra queries after restoring connection from cache ([@DmitryTsepelev][])
data/README.md CHANGED
@@ -252,7 +252,7 @@ Rails.application.configure do |config|
252
252
  end
253
253
  ```
254
254
 
255
- ⚠️ Cache store must implement `#read(key)` and `#write(key, value, **options)` methods.
255
+ ⚠️ Cache store must implement `#read(key)`, `#write(key, value, **options)` and `#exist?(key)` methods.
256
256
 
257
257
  The gem provides only in-memory store out-of-the-box (`GraphQL::FragmentCache::MemoryStore`). It's used by default.
258
258
 
@@ -16,8 +16,12 @@ module GraphQL
16
16
  @path = interpreter_context[:current_path]
17
17
  end
18
18
 
19
+ NIL_IN_CACHE = Object.new
20
+
19
21
  def read
20
- FragmentCache.cache_store.read(cache_key)
22
+ FragmentCache.cache_store.read(cache_key).tap do |cached|
23
+ return NIL_IN_CACHE if cached.nil? && FragmentCache.cache_store.exist?(cache_key)
24
+ end
21
25
  end
22
26
 
23
27
  def persist
@@ -23,6 +23,10 @@ module GraphQL
23
23
  @storage = {}
24
24
  end
25
25
 
26
+ def exist?(key)
27
+ storage.key?(key)
28
+ end
29
+
26
30
  def read(key)
27
31
  key = key.to_s
28
32
  storage[key]&.then do |entry|
@@ -22,6 +22,7 @@ module GraphQL
22
22
  fragment = Fragment.new(context, options)
23
23
 
24
24
  if (cached = fragment.read)
25
+ return nil if cached == Fragment::NIL_IN_CACHE
25
26
  return restore_cached_value(cached)
26
27
  end
27
28
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module FragmentCache
5
- VERSION = "0.1.7"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-fragment_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2020-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql