flipper-dalli 1.0.0.pre → 1.1.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: b06c02588ffb58a9e56d93eab3d04911c90a5b7250646ab11e732947864cef50
4
- data.tar.gz: a0a19a8e857b67644e1000477ea2400a5e244c4de0efcabf7c1d643e494f5d40
3
+ metadata.gz: 5ab7d84ca0cfcde7d80882fde5f30a65352291b9922e5fd19d6aa86ae360214f
4
+ data.tar.gz: 0eb5ae0eb3b124b16b6995a292554c1a7af72e0605036fad24066d8e8a9ef983
5
5
  SHA512:
6
- metadata.gz: ffc52c679b5eb5d4f0e0746cf0ca6ffd7ed01da5ec3ac2c6fa699887bdcfeea1ee4819d845187931e9184a10a859a6c20c01ea9258d2d42dc5e55835679f7944
7
- data.tar.gz: 2ac068f412b34da643adb7d4185ab0f22e96923aa6953bd4f26ad92be5b3c8d4d8b0d662fa69ef059cfe36743a1d07683ac5acb589fa5aed168ec4c5396341a3
6
+ metadata.gz: 9da38d17e220fc3924e1b7be24db7680a8bc85ccda6c759f1658942d001250336a67db362f0860b3706367569d29e16b22a5162bfb85693df8d867115cf7ff55
7
+ data.tar.gz: 1aeb61c9b9217dcc366342a4a7ce411992c2bd076ccab2238086ca1c7bf6df89f89cca07885f70364cda4490407e25bdee783a2a55212d94346a8c8b039a0f52
@@ -8,31 +8,22 @@ module Flipper
8
8
  class Dalli
9
9
  include ::Flipper::Adapter
10
10
 
11
- Version = 'v1'.freeze
12
- Namespace = "flipper/#{Version}".freeze
13
- FeaturesKey = "#{Namespace}/features".freeze
14
- GetAllKey = "#{Namespace}/get_all".freeze
15
-
16
- # Private
17
- def self.key_for(key)
18
- "#{Namespace}/feature/#{key}"
19
- end
20
-
21
11
  # Internal
22
12
  attr_reader :cache
23
13
 
24
- # Public: The name of the adapter.
25
- attr_reader :name
26
-
27
14
  # Public: The ttl for all cached data.
28
15
  attr_reader :ttl
29
16
 
30
17
  # Public
31
18
  def initialize(adapter, cache, ttl = 0)
32
19
  @adapter = adapter
33
- @name = :dalli
34
20
  @cache = cache
35
21
  @ttl = ttl
22
+
23
+ @cache_version = 'v1'.freeze
24
+ @namespace = "flipper/#{@cache_version}".freeze
25
+ @features_key = "#{@namespace}/features".freeze
26
+ @get_all_key = "#{@namespace}/get_all".freeze
36
27
  end
37
28
 
38
29
  # Public
@@ -43,14 +34,14 @@ module Flipper
43
34
  # Public
44
35
  def add(feature)
45
36
  result = @adapter.add(feature)
46
- @cache.delete(FeaturesKey)
37
+ @cache.delete(@features_key)
47
38
  result
48
39
  end
49
40
 
50
41
  # Public
51
42
  def remove(feature)
52
43
  result = @adapter.remove(feature)
53
- @cache.delete(FeaturesKey)
44
+ @cache.delete(@features_key)
54
45
  @cache.delete(key_for(feature.key))
55
46
  result
56
47
  end
@@ -74,12 +65,12 @@ module Flipper
74
65
  end
75
66
 
76
67
  def get_all
77
- if @cache.add(GetAllKey, Time.now.to_i, @ttl)
68
+ if @cache.add(@get_all_key, Time.now.to_i, @ttl)
78
69
  response = @adapter.get_all
79
70
  response.each do |key, value|
80
71
  @cache.set(key_for(key), value, @ttl)
81
72
  end
82
- @cache.set(FeaturesKey, response.keys.to_set, @ttl)
73
+ @cache.set(@features_key, response.keys.to_set, @ttl)
83
74
  response
84
75
  else
85
76
  features = read_feature_keys.map { |key| Flipper::Feature.new(key, self) }
@@ -104,11 +95,11 @@ module Flipper
104
95
  private
105
96
 
106
97
  def key_for(key)
107
- self.class.key_for(key)
98
+ "#{@namespace}/feature/#{key}"
108
99
  end
109
100
 
110
101
  def read_feature_keys
111
- @cache.fetch(FeaturesKey, @ttl) { @adapter.features }
102
+ @cache.fetch(@features_key, @ttl) { @adapter.features }
112
103
  end
113
104
 
114
105
  # Internal: Given an array of features, attempts to read through cache in
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '1.0.0.pre'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -26,7 +26,7 @@ RSpec.describe Flipper::Adapters::Dalli do
26
26
  feature = flipper[:stats]
27
27
  adapter.get(feature)
28
28
  adapter.remove(feature)
29
- expect(cache.get(described_class.key_for(feature))).to be(nil)
29
+ expect(cache.get("flipper/v1/#{feature.key}")).to be(nil)
30
30
  end
31
31
  end
32
32
 
@@ -41,13 +41,13 @@ RSpec.describe Flipper::Adapters::Dalli do
41
41
  memory_adapter.reset
42
42
 
43
43
  adapter.get(stats)
44
- expect(cache.get(described_class.key_for(search))).to be(nil)
45
- expect(cache.get(described_class.key_for(other))).to be(nil)
44
+ expect(cache.get("flipper/v1/feature/#{search.key}")).to be(nil)
45
+ expect(cache.get("flipper/v1/feature/#{other.key}")).to be(nil)
46
46
 
47
47
  adapter.get_multi([stats, search, other])
48
48
 
49
- expect(cache.get(described_class.key_for(search))[:boolean]).to eq('true')
50
- expect(cache.get(described_class.key_for(other))[:boolean]).to be(nil)
49
+ expect(cache.get("flipper/v1/feature/#{search.key}")[:boolean]).to eq('true')
50
+ expect(cache.get("flipper/v1/feature/#{other.key}")[:boolean]).to be(nil)
51
51
 
52
52
  adapter.get_multi([stats, search, other])
53
53
  adapter.get_multi([stats, search, other])
@@ -66,9 +66,9 @@ RSpec.describe Flipper::Adapters::Dalli do
66
66
 
67
67
  it 'warms all features' do
68
68
  adapter.get_all
69
- expect(cache.get(described_class.key_for(stats))[:boolean]).to eq('true')
70
- expect(cache.get(described_class.key_for(search))[:boolean]).to be(nil)
71
- expect(cache.get(described_class::GetAllKey)).to be_within(2).of(Time.now.to_i)
69
+ expect(cache.get("flipper/v1/feature/#{stats.key}")[:boolean]).to eq('true')
70
+ expect(cache.get("flipper/v1/feature/#{search.key}")[:boolean]).to be(nil)
71
+ expect(cache.get("flipper/v1/get_all")).to be_within(2).of(Time.now.to_i)
72
72
  end
73
73
 
74
74
  it 'returns same result when already cached' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-02 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flipper
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0.pre
19
+ version: 1.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0.pre
26
+ version: 1.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dalli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,9 +62,9 @@ licenses:
62
62
  metadata:
63
63
  documentation_uri: https://www.flippercloud.io/docs
64
64
  homepage_uri: https://www.flippercloud.io
65
- source_code_uri: https://github.com/jnunemaker/flipper
66
- bug_tracker_uri: https://github.com/jnunemaker/flipper/issues
67
- changelog_uri: https://github.com/jnunemaker/flipper/blob/main/Changelog.md
65
+ source_code_uri: https://github.com/flippercloud/flipper
66
+ bug_tracker_uri: https://github.com/flippercloud/flipper/issues
67
+ changelog_uri: https://github.com/flippercloud/flipper/blob/main/Changelog.md
68
68
  post_install_message:
69
69
  rdoc_options: []
70
70
  require_paths:
@@ -76,11 +76,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 1.3.1
81
+ version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.3.7
83
+ rubygems_version: 3.4.10
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Dalli adapter for Flipper