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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a243eb323248a618bbe87782c40fa7f537dcb5b1
4
- data.tar.gz: 81dfe8a47c0b3a64dc4e73589bdb4e70cd1aaabe
3
+ metadata.gz: 74b32e0596ff4feba607a2df4cd79ab969efb950
4
+ data.tar.gz: c990e4723dc5583b2bf2cd4c5364678a1a4557dc
5
5
  SHA512:
6
- metadata.gz: 3659805494943fbd42f2ea773baa4003d1716f187871a49740518187de05c9a671826cf0cd9dea0ec2416d4b400514a1ac336a725b6ea85bfdc5e01a802811c8
7
- data.tar.gz: 7dc6453f5f23bbe5955e8978b3e4acfe0ba79caf6dab861ecaf7fac971d2cce416c805ad1b5e7d91404fbd1fbaa0b88a68c5c04671812f71659e809aed4a0775
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.2-blue.png)](https://github.com/barcoo/redis_rds/releases/tag/0.1.2)
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
@@ -1,3 +1,3 @@
1
1
  module RedisRds
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
data/lib/redis_rds.rb CHANGED
@@ -7,6 +7,7 @@ require 'redis_rds/config'
7
7
  require 'redis_rds/composite'
8
8
  require 'redis_rds/object'
9
9
  require 'redis_rds/string'
10
+ require 'redis_rds/counter'
10
11
  require 'redis_rds/hash'
11
12
  require 'redis_rds/expirable_hash'
12
13
  require 'redis_rds/list'
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.3
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