Skip to content

Commit 33c53d7

Browse files
authored
Add #keys method to MemoryStore (#28)
1 parent 84f1f1a commit 33c53d7

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Gemfile.lock
1111
.rbnext/
1212
*.sqlite3
1313
spec/internal/log/*.log
14+
.idea/

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master
44

5+
## 1.0.2 (2020-08-19)
6+
7+
- [PR#28](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/28) Support #keys method for GraphQL::FragmentCache::MemoryStore instance ([@reabiliti][])
8+
59
## 1.0.1 (2020-06-17)
610

711
- [PR#25](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/25) Support fragments with aliases for CacheKeyBuilder ([@DmitryTsepelev][])
@@ -47,3 +51,4 @@
4751
[@DmitryTsepelev]: https://github.com/DmitryTsepelev
4852
[@palkan]: https://github.com/palkan
4953
[@ssnickolay]: https://github.com/ssnickolay
54+
[@reabiliti]: https://github.com/reabiliti

lib/graphql/fragment_cache/memory_store.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def initialize(expires_in: nil, **other)
2323
@storage = {}
2424
end
2525

26+
def keys
27+
storage.keys
28+
end
29+
2630
def exist?(key)
2731
storage.key?(key)
2832
end

spec/graphql/fragment_cache/memory_store_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@
5050
end
5151
end
5252

53+
context "supports keys interface" do
54+
it "returns actual keys" do
55+
subject.write(:test_1, "test_1")
56+
subject.write(:test_2, "test_2")
57+
expect(subject.keys).to eq %w[test_1 test_2]
58+
59+
subject.delete(:test_2)
60+
expect(subject.keys).to eq %w[test_1]
61+
end
62+
end
63+
5364
it "raises if unsupported options are passed" do
5465
expect { described_class.new(namespace: "test") }
5566
.to raise_error(ArgumentError, /unsupported options: namespace/i)

0 commit comments

Comments
 (0)