pause 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pause/redis/sharded_adapter.rb +13 -0
- data/lib/pause/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f681f5880476f055a00a8131eb6977aad96a0ba5
|
4
|
+
data.tar.gz: 282371534a8dcdb32dac098f479ee5df62433e85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9eb4591aa2533a7ea2759e7cb9c929de36ff32b75160701edc436d7ca12ca05dd91f6c72e9b09a4d5b9dfb3a3fcc234a9edd00860b6a6f2d3f60ff1c321ff0c
|
7
|
+
data.tar.gz: 397807c6f15cd909985b943f3b4b616484c9934025ed27124bed1f76728e0a7ab7e6721dd226135c56352b6b640786be6130210a0f34592d521c5bdf14a33023
|
@@ -7,6 +7,19 @@ module Pause
|
|
7
7
|
# Operations that are not possible when data is sharded
|
8
8
|
# raise an error.
|
9
9
|
class ShardedAdapter < Adapter
|
10
|
+
def increment(scope, identifier, timestamp, count = 1)
|
11
|
+
k = tracked_key(scope, identifier)
|
12
|
+
redis.zincrby k, count, period_marker(resolution, timestamp)
|
13
|
+
redis.expire k, history
|
14
|
+
|
15
|
+
if redis.zcard(k) > time_blocks_to_keep
|
16
|
+
list = extract_set_elements(k)
|
17
|
+
to_remove = list.slice(0, (list.size - time_blocks_to_keep))
|
18
|
+
redis.zrem(k, to_remove.map(&:ts))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
10
23
|
private
|
11
24
|
|
12
25
|
def redis
|
data/lib/pause/version.rb
CHANGED