redis_rds 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/lib/redis_rds/counter.rb +32 -0
- data/lib/redis_rds/version.rb +1 -1
- data/lib/redis_rds.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74b32e0596ff4feba607a2df4cd79ab969efb950
|
4
|
+
data.tar.gz: c990e4723dc5583b2bf2cd4c5364678a1a4557dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 493fc74b86a5cd91554cc0fba320e28f0dbec627356bc790697edf7c8b1a622d527574467d8bf756840b9fe187530fffe754b7c3d05324e4b661e43cc152b897
|
7
|
+
data.tar.gz: d7b8a3e8ddb08b2856dcf4cfa44432b2f1dad16017761889d818534a189a9c6077fa4d8350ba731e098b45a7aa2ae8cfd032b1e598c005317eeb03827c1ff59b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
##0.1.4
|
4
|
+
|
5
|
+
- [0752e21](https://github.com/barcoo/redis_rds/commit/0752e21) *2016-09-07* __require counter type__ (Nicolas Pepin-Perreault)
|
6
|
+
- [ddbc82c](https://github.com/barcoo/redis_rds/commit/ddbc82c) *2016-09-07* __added temporary counter type__ (Nicolas Pepin-Perreault)
|
7
|
+
- [6d993d8](https://github.com/barcoo/redis_rds/commit/6d993d8) *2016-09-07* __version bump__ (Nicolas Pepin-Perreault)
|
8
|
+
- [985b54e](https://github.com/barcoo/redis_rds/commit/985b54e) *2016-09-07* __updated String#set to have more options supported by redis__ (Nicolas Pepin-Perreault)
|
9
|
+
|
3
10
|
##0.1.2
|
4
11
|
|
5
12
|
- [3651e53](https://github.com/barcoo/redis_rds/commit/3651e53) *2016-08-02* __updated rake release task__ (Nicolas Pepin-Perreault)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RedisRds
|
2
2
|
|
3
|
-
[![GitHub release](https://img.shields.io/badge/release-0.1.
|
3
|
+
[![GitHub release](https://img.shields.io/badge/release-0.1.4-blue.png)](https://github.com/barcoo/redis_rds/releases/tag/0.1.4)
|
4
4
|
[![Build Status](https://travis-ci.org/barcoo/redis_rds.svg?branch=master)](https://travis-ci.org/barcoo/redis_rds)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/barcoo/redis_rds/badge.svg?branch=master&update=now)](https://coveralls.io/github/barcoo/redis_rds?branch=master)
|
6
6
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RedisRds
|
2
|
+
class Counter < RedisRds::String
|
3
|
+
# Disable warning since one cannot freeze multiline heredocs...
|
4
|
+
# rubocop: disable Style/MutableConstant
|
5
|
+
RING_INCREMENT_SCRIPT = <<~LUA
|
6
|
+
local by = tonumber(ARGV[1])
|
7
|
+
local max = tonumber(ARGV[2])
|
8
|
+
local current = redis.call('get', KEYS[1])
|
9
|
+
local value = current and tonumber(current) or 0
|
10
|
+
|
11
|
+
value = (value + by) % max
|
12
|
+
redis.call('set', KEYS[1], value)
|
13
|
+
|
14
|
+
return value
|
15
|
+
LUA
|
16
|
+
|
17
|
+
def incrby(increment, max: nil)
|
18
|
+
value = if max.nil?
|
19
|
+
super(increment)
|
20
|
+
else
|
21
|
+
ring_increment_script(increment.to_i, max.to_i).to_i
|
22
|
+
end
|
23
|
+
|
24
|
+
return value
|
25
|
+
end
|
26
|
+
|
27
|
+
def ring_increment_script(increment, max)
|
28
|
+
return connection.eval(RING_INCREMENT_SCRIPT, [@redis_key], [increment, max])
|
29
|
+
end
|
30
|
+
private :ring_increment_script
|
31
|
+
end
|
32
|
+
end
|
data/lib/redis_rds/version.rb
CHANGED
data/lib/redis_rds.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_rds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Checkitmobile GmbH
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/redis_rds.rb
|
118
118
|
- lib/redis_rds/composite.rb
|
119
119
|
- lib/redis_rds/config.rb
|
120
|
+
- lib/redis_rds/counter.rb
|
120
121
|
- lib/redis_rds/expirable_hash.rb
|
121
122
|
- lib/redis_rds/hash.rb
|
122
123
|
- lib/redis_rds/list.rb
|