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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35b5e5cfc4873a689448142620660d1666616b8a
4
- data.tar.gz: fb129440f8573bc3c27986ad89db70ff9f1dceb1
3
+ metadata.gz: 6fd118eb5226c33b0874c6bf075e4f909fb8c89b
4
+ data.tar.gz: eaa5da83190736b220d0b9170a7724e617b8758f
5
5
  SHA512:
6
- metadata.gz: a45ebd0bbedbf872526e0208c87172e7f28f736cbbf064bfb23baf39468bb0ab6bb5d0a1d1f6c06f4baa9d0091472c0b1cf4827b08ded1b51db7099305ac8d7e
7
- data.tar.gz: b481b19b93d9a097e2ab2514e3158d1d0f6a457f807fb705804e50bf190549baa5865b7d005affdc5d5c209494308573f49382253ce5b015284c0615fb24c4e0
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
@@ -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
@@ -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
@@ -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
@@ -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=? and column1 = ?", value, key, column1)
3
+ execute("update counters set value = value + ? where key = ? and column1 = ?", value, key.to_s, column1.to_s)
4
4
  end
5
5
  end
@@ -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
@@ -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
@@ -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"]
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def hset key, column1, value
3
- execute("UPDATE hashes SET value = ? WHERE column1 = ? and key = ?", value, column1, key)
3
+ execute("UPDATE hashes SET value = ? WHERE column1 = ? and key = ?", value, column1.to_s, key.to_s)
4
4
  end
5
5
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def lpush namespace, data
3
- execute("UPDATE lists SET values = ? + values WHERE namespace = ?", [ data], namespace)
3
+ execute("UPDATE lists SET values = ? + values WHERE namespace = ?", [ data], namespace.to_s)
4
4
  end
5
5
  end
@@ -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]
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def rpush namespace, data
3
- execute("UPDATE lists SET values = values + [?] WHERE namespace = ?", data, namespace)
3
+ execute("UPDATE lists SET values = values + [?] WHERE namespace = ?", data, namespace.to_s)
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def sadd key, *members
3
- execute("update sets set members = members + ? where key = ?", members, key)
3
+ execute("update sets set members = members + ? where key = ?", members, key.to_s)
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def sadd_with_expire( key, ttl, *members)
3
- execute("update sets using ttl ? set members = members + ? where key = ?", ttl, members, key)
3
+ execute("update sets using ttl ? set members = members + ? where key = ?", ttl, members, key.to_s)
4
4
  end
5
5
  end
data/lib/redi2casa/set.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def set key, value
3
- execute("UPDATE keyvalue set value = ? where key = ?", value, key)
3
+ execute("UPDATE keyvalue set value = ? where key = ?", value, key.to_s)
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def setex key, ttl, value
3
- execute("UPDATE keyvalue using TTL ? set value = ? where key = ?", ttl, value, key)
3
+ execute("UPDATE keyvalue using TTL ? set value = ? where key = ?", ttl, value, key.to_s)
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  class Redi2casa
2
2
  def smembers key
3
- resp = execute("select * from sets where key = ?", key)
3
+ resp = execute("select * from sets where key = ?", key.to_s)
4
4
  if resp.first
5
5
  resp.first["members"].to_a
6
6
  else
@@ -1,5 +1,5 @@
1
1
  class Redi2casa
2
2
  def srem key, member
3
- execute("update sets set members = members - {'#{member}'} where key = ?", key)
3
+ execute("update sets set members = members - {'#{member}'} where key = ?", key.to_s)
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  class Redi2casa
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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']
@@ -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'])
@@ -1,6 +1,6 @@
1
1
  class Redi2casa
2
2
  def zscore key, value
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
  return entry['score'] if entry['value'] == value.to_s
6
6
  end
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.5
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-13 00:00:00.000000000 Z
12
+ date: 2014-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cql-rb