redi2casa 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Examples.md +32 -33
- data/Gemfile.lock +3 -1
- data/cassandra_cli_cmds +1 -0
- data/cqlsh_cmds +2 -3
- data/lib/redi2casa/hdel.rb +9 -0
- data/lib/redi2casa/hget.rb +5 -5
- data/lib/redi2casa/hgetall.rb +4 -4
- data/lib/redi2casa/hincrby.rb +2 -3
- data/lib/redi2casa/hkeys.rb +11 -0
- data/lib/redi2casa/hlen.rb +7 -0
- data/lib/redi2casa/hset.rb +2 -2
- data/lib/redi2casa/sadd_with_expire.rb +1 -1
- data/lib/redi2casa/scard.rb +5 -0
- data/lib/redi2casa/sismember.rb +5 -0
- data/lib/redi2casa/version.rb +1 -1
- data/redi2casa.gemspec +1 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d5b3420d36a8292cb6d06c1a4e0233731ad4446
|
4
|
+
data.tar.gz: 415d1260880d010fbd378cdc5d33d8c024b9719a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1c2e4898460665dda13bc1c6ceeb97e21089a9d19445eb3bd8244c7e9d8ef874db846cba4323795c325588d69bb4dd66119f3090872e1adaa96f73e575a6067
|
7
|
+
data.tar.gz: 8163288c905fa1845881c8b359c576d0a5a7c6fdf0164910faf6142b230ff4221232607899277c52b3588548d8346cf7ac7ee386aa15d13f5e888c84b000320c
|
data/Examples.md
CHANGED
@@ -1,52 +1,51 @@
|
|
1
1
|
r = Redi2casa.new([localhost], 'redi2casa')
|
2
2
|
|
3
|
-
|
4
|
-
# Do not mix counters and non-counter values in a single Hash
|
3
|
+
### Do not mix counters and non-counter values in a single Hash
|
5
4
|
|
6
5
|
Hash - counters
|
7
6
|
---------------
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
Increment: r.hicnrby "c", "e", 10
|
9
|
+
r.hget "c", "e" => 10
|
10
|
+
Decrement: r.hincrby "c", "e", -10
|
11
|
+
r.hget "c", "e" => 0
|
12
|
+
r.hincrby "c", "a", 100
|
13
|
+
r.hgetall "c" => { "a" => 100, "e" => 0 }
|
14
14
|
|
15
|
-
|
15
|
+
## r.hset does not work for counters as yet ##
|
16
16
|
|
17
|
-
## r.hset does not work for counters as yet ##
|
18
17
|
|
19
18
|
Hash - Non-counters
|
20
19
|
-------------------
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
|
21
|
+
r.hset "a", "b", "hello_world"
|
22
|
+
r.hset "a", "b", "bye_world"
|
23
|
+
r.hget "a", "b" => "hello_world"
|
24
|
+
|
25
|
+
r.hgetall "a" => {"a" => "hello_world", "b" => "bye_world"}
|
27
26
|
|
28
27
|
List
|
29
28
|
-----
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
r.lpush "a", "hello"
|
31
|
+
r.lpush "a", "hello1"
|
32
|
+
r.rpush "a", "hello3"
|
33
|
+
|
34
|
+
r.lrange "a", 0, -1 => ["hello", "hello1", "hello3"]
|
35
|
+
r.lpop "a" => "hello"
|
36
|
+
r.lrange "a", 0, -1 => ["hello1", "hello3"]
|
37
|
+
|
38
|
+
r.rpop "a" => "hello3"
|
39
|
+
r.lrange "a", 0, -1 => ["hello1"]
|
41
40
|
|
42
41
|
|
43
42
|
Key-value pairs
|
44
43
|
---------------
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
|
45
|
+
r.set "a", "welcome"
|
46
|
+
r.get "a" => "welcome"
|
47
|
+
|
48
|
+
r.setex "a", 10, "c"
|
49
|
+
r.get "a" => "c"
|
50
|
+
### after 10 seconds
|
51
|
+
r.get "a" => nil
|
data/Gemfile.lock
CHANGED
data/cassandra_cli_cmds
CHANGED
@@ -1 +1,2 @@
|
|
1
1
|
create column family counters with column_type = 'Standard' and comparator = 'UTF8Type' and default_validation_class = 'CounterColumnType' and key_validation_class = 'UTF8Type';
|
2
|
+
create column family hashes with column_type = 'Standard' and comparator = 'UTF8Type' and default_validation_class = 'UTF8Type' and key_validation_class = 'UTF8Type';
|
data/cqlsh_cmds
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
1
|
+
create keyspace redi2casa WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
2
2
|
use redi2casa;
|
3
|
-
create table hashes(namespace text primary key, key map<text, text>);
|
4
3
|
create table lists(namespace text primary key, values list<text>);
|
5
4
|
create table keyvalue(key text primary key, value text);
|
6
|
-
create table sets(key text primary key,
|
5
|
+
create table sets(key text primary key, members set<text>);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class Redi2casa
|
2
|
+
def hdel key, column1, type = "counter"
|
3
|
+
if type == "counter"
|
4
|
+
@db_conn.execute("delete from counters where key = '#{key}' and column1 = '#{column1}'")
|
5
|
+
elsif type == "hash"
|
6
|
+
@db_conn.execute("delete from hashes where key = '#{key}' and column1 = '#{column1}'")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/redi2casa/hget.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Redi2casa
|
2
|
-
def hget
|
2
|
+
def hget key, column1, type = "counter"
|
3
3
|
if type.to_s == "hash"
|
4
|
-
resp = @db_conn.execute("select
|
5
|
-
parse_response(resp, "key")
|
6
|
-
elsif type.to_s == "counters"
|
7
|
-
resp = @db_conn.execute("select value from counters where KEY='#{namespace}' and column1 = '#{key}'")
|
4
|
+
resp = @db_conn.execute("select value from hashes where key = '#{key}' and column1 = '#{column1}'")
|
8
5
|
parse_response(resp, "value")
|
6
|
+
elsif type.to_s == "counter"
|
7
|
+
resp = @db_conn.execute("select value from counters where KEY='#{key}' and column1 = '#{column1}'")
|
8
|
+
parse_response(resp, "value").to_i
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/redi2casa/hgetall.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Redi2casa
|
2
|
-
def hgetall key, type = "
|
3
|
-
if type.to_s == "
|
2
|
+
def hgetall key, type = "counter"
|
3
|
+
if type.to_s == "counter"
|
4
4
|
response = @db_conn.execute("select * from counters where KEY='#{key}'")
|
5
5
|
response.inject({}) {|hsh, entry| hsh[entry["column1"]] = entry["value"]; hsh}
|
6
6
|
elsif type.to_s == "hash"
|
7
|
-
|
8
|
-
|
7
|
+
response = @db_conn.execute("select * from hashes where key = '#{key}'")
|
8
|
+
response.inject({}) {|hsh, entry| hsh[entry["column1"]] = entry["value"]; hsh}
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/redi2casa/hincrby.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class Redi2casa
|
2
|
-
def hincrby
|
3
|
-
|
4
|
-
@db_conn.execute(query)
|
2
|
+
def hincrby key, column1, value = 1
|
3
|
+
@db_conn.execute("update counters set value = value + #{value} where key='#{key}' and column1 = '#{column1}'")
|
5
4
|
end
|
6
5
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Redi2casa
|
2
|
+
def hkeys key, type = "counter"
|
3
|
+
if type.to_s == "counter"
|
4
|
+
response = @db_conn.execute("select column1 from counters where key = '#{key}'")
|
5
|
+
response.collect {|entry| entry["column1"]}
|
6
|
+
elsif type.to_s == "hash"
|
7
|
+
response = @db_conn.execute("select column1 from hashes where key = '#{key}'")
|
8
|
+
response.collect {|entry| entry["column1"]}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/redi2casa/hset.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Redi2casa
|
2
|
-
def hset
|
3
|
-
@db_conn.execute("UPDATE hashes SET
|
2
|
+
def hset key, column1, value
|
3
|
+
@db_conn.execute("UPDATE hashes SET value = '#{value}' WHERE column1 = '#{column1}' and key = '#{key}'")
|
4
4
|
end
|
5
5
|
end
|
data/lib/redi2casa/version.rb
CHANGED
data/redi2casa.gemspec
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.0.
|
4
|
+
version: 0.0.5
|
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: 2013-
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cql-rb
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bitwise
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: cql-rb
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -87,9 +101,12 @@ files:
|
|
87
101
|
- lib/redi2casa.rb
|
88
102
|
- lib/redi2casa/del.rb
|
89
103
|
- lib/redi2casa/get.rb
|
104
|
+
- lib/redi2casa/hdel.rb
|
90
105
|
- lib/redi2casa/hget.rb
|
91
106
|
- lib/redi2casa/hgetall.rb
|
92
107
|
- lib/redi2casa/hincrby.rb
|
108
|
+
- lib/redi2casa/hkeys.rb
|
109
|
+
- lib/redi2casa/hlen.rb
|
93
110
|
- lib/redi2casa/hset.rb
|
94
111
|
- lib/redi2casa/lpop.rb
|
95
112
|
- lib/redi2casa/lpush.rb
|
@@ -99,8 +116,10 @@ files:
|
|
99
116
|
- lib/redi2casa/rpush.rb
|
100
117
|
- lib/redi2casa/sadd.rb
|
101
118
|
- lib/redi2casa/sadd_with_expire.rb
|
119
|
+
- lib/redi2casa/scard.rb
|
102
120
|
- lib/redi2casa/set.rb
|
103
121
|
- lib/redi2casa/setex.rb
|
122
|
+
- lib/redi2casa/sismember.rb
|
104
123
|
- lib/redi2casa/smembers.rb
|
105
124
|
- lib/redi2casa/spop.rb
|
106
125
|
- lib/redi2casa/srem.rb
|