redi2casa 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redi2casa/del.rb +5 -5
- data/lib/redi2casa/get.rb +2 -2
- data/lib/redi2casa/hdel.rb +1 -1
- data/lib/redi2casa/hget.rb +2 -2
- data/lib/redi2casa/hgetall.rb +2 -2
- data/lib/redi2casa/hincrby.rb +1 -1
- data/lib/redi2casa/hkeys.rb +2 -2
- data/lib/redi2casa/hlen.rb +2 -2
- data/lib/redi2casa/hmget.rb +1 -1
- data/lib/redi2casa/hset.rb +1 -1
- data/lib/redi2casa/lpop.rb +1 -1
- data/lib/redi2casa/lpush.rb +1 -1
- data/lib/redi2casa/lrange.rb +1 -1
- data/lib/redi2casa/ltrim.rb +3 -3
- data/lib/redi2casa/rpop.rb +1 -1
- data/lib/redi2casa/rpush.rb +1 -1
- data/lib/redi2casa/sadd.rb +1 -1
- data/lib/redi2casa/sadd_with_expire.rb +1 -1
- data/lib/redi2casa/set.rb +1 -1
- data/lib/redi2casa/setex.rb +1 -1
- data/lib/redi2casa/smembers.rb +1 -1
- data/lib/redi2casa/srem.rb +1 -1
- data/lib/redi2casa/version.rb +1 -1
- data/lib/redi2casa/zadd.rb +1 -1
- data/lib/redi2casa/zrangebyscore.rb +2 -2
- data/lib/redi2casa/zrem.rb +1 -1
- data/lib/redi2casa/zscore.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fd118eb5226c33b0874c6bf075e4f909fb8c89b
|
4
|
+
data.tar.gz: eaa5da83190736b220d0b9170a7724e617b8758f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9daf2b3d76a10112131e9e73148e747e64a59bac4cde5803b240dba5483f8f12c85c19d16c81a1dcfc2aaf2f63e1b67ca7dc59c8d18a11a1e1fd77eb9f2d0d0
|
7
|
+
data.tar.gz: 39f6d0eba76002916ed6b3d408a694ff17a3babcf8bfa8605fdb62ae7c6a9f8462c26186b882812628966b0c7fb85f0f2b12a49c80adfb5ba0afe7c0de816630
|
data/lib/redi2casa/del.rb
CHANGED
@@ -4,15 +4,15 @@ class Redi2casa
|
|
4
4
|
if type == "counter"
|
5
5
|
raise RuntimeError.new("deleting counters is not supported")
|
6
6
|
elsif type == 'keyvalue'
|
7
|
-
execute("delete from keyvalue where key = ?", key)
|
7
|
+
execute("delete from keyvalue where key = ?", key.to_s)
|
8
8
|
elsif type == 'hash'
|
9
|
-
execute("delete from hashes where key = ?", key)
|
9
|
+
execute("delete from hashes where key = ?", key.to_s)
|
10
10
|
elsif type == 'list'
|
11
|
-
execute("delete from lists where namespace = ?", key)
|
11
|
+
execute("delete from lists where namespace = ?", key.to_s)
|
12
12
|
elsif type == 'set'
|
13
|
-
execute("delete from sets where key = ?", key)
|
13
|
+
execute("delete from sets where key = ?", key.to_s)
|
14
14
|
elsif type == 'sorted_set'
|
15
|
-
execute("delete from sorted_sets where key = ?", key)
|
15
|
+
execute("delete from sorted_sets where key = ?", key.to_s)
|
16
16
|
else
|
17
17
|
raise RuntimeError.new("Invalid type")
|
18
18
|
end
|
data/lib/redi2casa/get.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def get key, type = 'keyvalue'
|
3
3
|
if type == 'keyvalue'
|
4
|
-
resp = execute("select * from keyvalue where key = ?", key)
|
4
|
+
resp = execute("select * from keyvalue where key = ?", key.to_s)
|
5
5
|
parse_response(resp, "value")
|
6
6
|
elsif type == 'counter'
|
7
7
|
# @ is a special column in counter used by incrby
|
8
|
-
resp = execute("select value from counters where KEY = ? and column1 = '@'", key)
|
8
|
+
resp = execute("select value from counters where KEY = ? and column1 = '@'", key.to_s)
|
9
9
|
parse_response(resp, "value").to_i
|
10
10
|
end
|
11
11
|
end
|
data/lib/redi2casa/hdel.rb
CHANGED
@@ -3,7 +3,7 @@ class Redi2casa
|
|
3
3
|
if type == "counter"
|
4
4
|
raise RuntimeError.new("deleting counters is not supported")
|
5
5
|
elsif type == "hash"
|
6
|
-
execute("delete from hashes where key = ? and column1 = ?", key, column1)
|
6
|
+
execute("delete from hashes where key = ? and column1 = ?", key.to_s, column1.to_s)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
data/lib/redi2casa/hget.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def hget key, column1, type = "counter"
|
3
3
|
if type.to_s == "hash"
|
4
|
-
resp = execute("select value from hashes where key = ? and column1 = ?", key, column1)
|
4
|
+
resp = execute("select value from hashes where key = ? and column1 = ?", key.to_s, column1.to_s)
|
5
5
|
parse_response(resp, "value")
|
6
6
|
elsif type.to_s == "counter"
|
7
|
-
resp = execute("select value from counters where key = ? and column1 = ?", key, column1)
|
7
|
+
resp = execute("select value from counters where key = ? and column1 = ?", key.to_s, column1.to_s)
|
8
8
|
parse_response(resp, "value").to_i
|
9
9
|
end
|
10
10
|
end
|
data/lib/redi2casa/hgetall.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def hgetall key, type = "counter"
|
3
3
|
if type.to_s == "counter"
|
4
|
-
response = execute("select * from counters where KEY = ?", key)
|
4
|
+
response = execute("select * from counters where KEY = ?", key.to_s)
|
5
5
|
response.inject({}) {|hsh, entry| hsh[entry["column1"]] = entry["value"]; hsh}
|
6
6
|
elsif type.to_s == "hash"
|
7
|
-
response = execute("select * from hashes where KEY = ?", key)
|
7
|
+
response = execute("select * from hashes where KEY = ?", key.to_s)
|
8
8
|
response.inject({}) {|hsh, entry| hsh[entry["column1"]] = entry["value"]; hsh}
|
9
9
|
end
|
10
10
|
end
|
data/lib/redi2casa/hincrby.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def hincrby key, column1, value = 1
|
3
|
-
execute("update counters set value = value + ? where key
|
3
|
+
execute("update counters set value = value + ? where key = ? and column1 = ?", value, key.to_s, column1.to_s)
|
4
4
|
end
|
5
5
|
end
|
data/lib/redi2casa/hkeys.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def hkeys key, type = "counter"
|
3
3
|
if type.to_s == "counter"
|
4
|
-
response = execute("select column1 from counters where key = ?", key)
|
4
|
+
response = execute("select column1 from counters where key = ?", key.to_s)
|
5
5
|
elsif type.to_s == "hash"
|
6
|
-
response = execute("select column1 from hashes where key = ?", key)
|
6
|
+
response = execute("select column1 from hashes where key = ?", key.to_s)
|
7
7
|
else
|
8
8
|
raise RuntimeError.new("Invalid type")
|
9
9
|
end
|
data/lib/redi2casa/hlen.rb
CHANGED
@@ -2,9 +2,9 @@ class Redi2casa
|
|
2
2
|
# Supports only hashes now
|
3
3
|
def hlen key, type = "hash"
|
4
4
|
if type == "hash"
|
5
|
-
response = execute("select count(*) from hashes where key = ?", key)
|
5
|
+
response = execute("select count(*) from hashes where key = ?", key.to_s)
|
6
6
|
elsif type == "counter"
|
7
|
-
response = execute("select count(*) from counters where key = ?", key)
|
7
|
+
response = execute("select count(*) from counters where key = ?", key.to_s)
|
8
8
|
else
|
9
9
|
raise RuntimeError.new("Invalid type")
|
10
10
|
end
|
data/lib/redi2casa/hmget.rb
CHANGED
@@ -8,7 +8,7 @@ class Redi2casa
|
|
8
8
|
raise RuntimeError.new("invalid table")
|
9
9
|
end
|
10
10
|
|
11
|
-
resp = execute("select column1, value from #{table} where key = ? and column1 IN ?", key, column1s)
|
11
|
+
resp = execute("select column1, value from #{table} where key = ? and column1 IN ?", key.to_s, column1s)
|
12
12
|
hash = {}
|
13
13
|
resp.each do |r|
|
14
14
|
hash[r["column1"]] = r["value"]
|
data/lib/redi2casa/hset.rb
CHANGED
data/lib/redi2casa/lpop.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
#has a read modify write problem
|
3
3
|
def lpop namespace
|
4
|
-
resp = execute("select values from lists where namespace = ?", namespace)
|
4
|
+
resp = execute("select values from lists where namespace = ?", namespace.to_s)
|
5
5
|
values = []
|
6
6
|
resp.each {|entry| values = entry.to_hash["values"]}
|
7
7
|
resp = values.shift
|
data/lib/redi2casa/lpush.rb
CHANGED
data/lib/redi2casa/lrange.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def lrange namespace, first, last
|
3
|
-
resp = execute("select values from lists where namespace = ?", namespace)
|
3
|
+
resp = execute("select values from lists where namespace = ?", namespace.to_s)
|
4
4
|
resp.each {|entry|
|
5
5
|
values = entry.to_hash["values"] || []
|
6
6
|
return values[first..last]
|
data/lib/redi2casa/ltrim.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def ltrim namespace, first, last
|
3
|
-
resp = execute("select values from lists where namespace = ?", namespace)
|
3
|
+
resp = execute("select values from lists where namespace = ?", namespace.to_s)
|
4
4
|
values = {}
|
5
5
|
resp.each {|entry| values = entry.to_hash["values"]}
|
6
6
|
values_count = values.count
|
@@ -17,11 +17,11 @@ class Redi2casa
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def lflush namespace
|
20
|
-
execute("UPDATE lists SET values = [] WHERE namespace = ?", namespace)
|
20
|
+
execute("UPDATE lists SET values = [] WHERE namespace = ?", namespace.to_s)
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
24
24
|
def lrepush namespace, list
|
25
|
-
execute("UPDATE lists SET values = ? WHERE namespace = ?", list, namespace)
|
25
|
+
execute("UPDATE lists SET values = ? WHERE namespace = ?", list, namespace.to_s)
|
26
26
|
end
|
27
27
|
end
|
data/lib/redi2casa/rpop.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def rpop namespace
|
3
|
-
resp = execute("select values from lists where namespace = ?", namespace)
|
3
|
+
resp = execute("select values from lists where namespace = ?", namespace.to_s)
|
4
4
|
values = []
|
5
5
|
resp.fetch {|entry| values = entry.to_hash["values"]}
|
6
6
|
resp = values.pop
|
data/lib/redi2casa/rpush.rb
CHANGED
data/lib/redi2casa/sadd.rb
CHANGED
data/lib/redi2casa/set.rb
CHANGED
data/lib/redi2casa/setex.rb
CHANGED
data/lib/redi2casa/smembers.rb
CHANGED
data/lib/redi2casa/srem.rb
CHANGED
data/lib/redi2casa/version.rb
CHANGED
data/lib/redi2casa/zadd.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
# Random text is an extra column added to make sure we have multiple entries with same key, score and value
|
3
3
|
def zadd key, score, value
|
4
|
-
execute("insert into sorted_sets (key, score,value, random_text) values (?, ?, ?, ?)", key, score, value, Time.now.to_i.to_s)
|
4
|
+
execute("insert into sorted_sets (key, score,value, random_text) values (?, ?, ?, ?)", key.to_s, score, value, Time.now.to_i.to_s)
|
5
5
|
end
|
6
6
|
end
|
@@ -2,9 +2,9 @@ class Redi2casa
|
|
2
2
|
# Ranges are exclusive
|
3
3
|
def zrangebyscore key, lower_limit, higher_limit = -1
|
4
4
|
if higher_limit == -1
|
5
|
-
resp = execute("select value from sorted_sets where key = ? and score > ?", key, lower_limit)
|
5
|
+
resp = execute("select value from sorted_sets where key = ? and score > ?", key.to_s, lower_limit)
|
6
6
|
else
|
7
|
-
resp = execute("select value from sorted_sets where key = ? and score > ? and score < ?", key, lower_limit, higher_limit)
|
7
|
+
resp = execute("select value from sorted_sets where key = ? and score > ? and score < ?", key.to_s, lower_limit, higher_limit)
|
8
8
|
end
|
9
9
|
resp.collect do |entry|
|
10
10
|
entry['value']
|
data/lib/redi2casa/zrem.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Redi2casa
|
2
2
|
def zrem key, member
|
3
|
-
resp = execute("select * from sorted_sets where key = ?", key)
|
3
|
+
resp = execute("select * from sorted_sets where key = ?", key.to_s)
|
4
4
|
resp.each do |entry|
|
5
5
|
if entry['value'] == member.to_s
|
6
6
|
execute("delete from sorted_sets where key = ? and score = ? and value = ?", key, entry['score'], entry['value'])
|
data/lib/redi2casa/zscore.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redi2casa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vireshas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cql-rb
|