kredis 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kredis might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/kredis/attributes.rb +16 -0
- data/lib/kredis/types.rb +5 -0
- data/lib/kredis/types/flag.rb +13 -0
- data/lib/kredis/types/list.rb +2 -2
- data/lib/kredis/types/unique_list.rb +2 -2
- data/lib/kredis/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c81a934c4d3b042045d49c96450e86c681529411fe5de467698d213f66bf21
|
4
|
+
data.tar.gz: b5d81f606b35fa29ebccd67940c4fd8d6f01c59d5957b0f3fb5aabf06c0f3896
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dff036d7c5dfecb9e755d991419622cc2456a7eb4f79ea7a1a317156fc5ba87525b339f92726a19062c43716c23dce707ab1ec80253852dc79fed7a48cfade3
|
7
|
+
data.tar.gz: 64928a2e0d7c9ada0a51515dc8405339f053b5579f0cd57f109a52a38e23461a9be164db72c5fbb0eb0af8ff8fee3fb813e21c468b0d3e90c4a6a75747d7b777
|
data/lib/kredis/attributes.rb
CHANGED
@@ -25,6 +25,22 @@ module Kredis::Attributes
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
def kredis_flag(name, config: :shared)
|
30
|
+
ivar_symbol = :"@#{name}_kredis_flag"
|
31
|
+
|
32
|
+
define_method(name) do
|
33
|
+
if instance_variable_defined?(ivar_symbol)
|
34
|
+
instance_variable_get(ivar_symbol)
|
35
|
+
else
|
36
|
+
instance_variable_set(ivar_symbol, Kredis.flag(kredis_key_for_attribute(name), config: config))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
define_method("#{name}?") do
|
41
|
+
instance_variable_defined?(ivar_symbol) && instance_variable_get(ivar_symbol).marked?
|
42
|
+
end
|
43
|
+
end
|
28
44
|
end
|
29
45
|
|
30
46
|
private
|
data/lib/kredis/types.rb
CHANGED
@@ -15,6 +15,10 @@ module Kredis::Types
|
|
15
15
|
Counter.new configured_for(config), namespaced_key(key), expires_in: expires_in
|
16
16
|
end
|
17
17
|
|
18
|
+
def flag(key, config: :shared)
|
19
|
+
Flag.new configured_for(config), namespaced_key(key)
|
20
|
+
end
|
21
|
+
|
18
22
|
def mutex(key, expires_in: nil, config: :shared)
|
19
23
|
Mutex.new configured_for(config), namespaced_key(key), expires_in: expires_in
|
20
24
|
end
|
@@ -24,4 +28,5 @@ require "kredis/proxy"
|
|
24
28
|
require "kredis/types/list"
|
25
29
|
require "kredis/types/unique_list"
|
26
30
|
require "kredis/types/counter"
|
31
|
+
require "kredis/types/flag"
|
27
32
|
require "kredis/types/mutex"
|
data/lib/kredis/types/list.rb
CHANGED
@@ -10,7 +10,7 @@ class Kredis::Types::UniqueList < Kredis::Types::List
|
|
10
10
|
remove elements
|
11
11
|
super
|
12
12
|
ltrim 0, (@limit - 1) if @limit
|
13
|
-
end
|
13
|
+
end if Array(elements).any?
|
14
14
|
end
|
15
15
|
|
16
16
|
def append(elements)
|
@@ -18,6 +18,6 @@ class Kredis::Types::UniqueList < Kredis::Types::List
|
|
18
18
|
remove elements
|
19
19
|
super
|
20
20
|
ltrim (@limit - 1), -1 if @limit
|
21
|
-
end
|
21
|
+
end if Array(elements).any?
|
22
22
|
end
|
23
23
|
end
|
data/lib/kredis/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kredis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Timm Hansen
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/kredis/railtie.rb
|
56
56
|
- lib/kredis/types.rb
|
57
57
|
- lib/kredis/types/counter.rb
|
58
|
+
- lib/kredis/types/flag.rb
|
58
59
|
- lib/kredis/types/list.rb
|
59
60
|
- lib/kredis/types/mutex.rb
|
60
61
|
- lib/kredis/types/unique_list.rb
|