redi2casa 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +1 -0
- data/lib/redi2casa/hget.rb +11 -0
- data/lib/redi2casa/hgetall.rb +13 -0
- data/lib/redi2casa/hincrby.rb +6 -0
- data/lib/redi2casa/hset.rb +6 -0
- data/lib/redi2casa/version.rb +3 -0
- data/lib/redi2casa.rb +9 -0
- data/redi2casa.gemspec +23 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Redi2casa
|
2
|
+
|
3
|
+
Redis datastructures using Cassandra
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'redi2casa'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install redi2casa
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
#### create these tables
|
21
|
+
cqlsh: create table sets(namespace text primary key, key map<text, text>);
|
22
|
+
cassandra-cli: create column family counters with column_type = 'Standard' and comparator = 'UTF8Type' and default_validation_class = 'CounterColumnType' and key_validation_class = 'UTF8Type';
|
23
|
+
|
24
|
+
### Now you can
|
25
|
+
require "redi2casa"
|
26
|
+
r = Redi2casa.new "127.0.0.1:9160", {:keyspace => 'keyspace1'}
|
27
|
+
|
28
|
+
#### hincrby & hget
|
29
|
+
|
30
|
+
Increment: r.hincrby "c", "e", 10
|
31
|
+
Decrement: r.hincrby "c", "e", -10
|
32
|
+
r.hget "c", "e", "counters"
|
33
|
+
|
34
|
+
#### hset & hget
|
35
|
+
|
36
|
+
r.hset "a", "b", "hello_world"
|
37
|
+
r.hget "a", "b", "sets"
|
38
|
+
|
39
|
+
#### hgetall
|
40
|
+
|
41
|
+
r.hgetall "c", "counters"
|
42
|
+
r.hgetall "a", "sets"
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Redi2casa
|
2
|
+
def hget namespace, key, type = "counters"
|
3
|
+
if type.to_s == "sets"
|
4
|
+
resp = @db_conn.execute("select * from sets where namespace = ?", namespace).fetch
|
5
|
+
resp.nil? ? nil : resp.to_hash['key'][key]
|
6
|
+
elsif type.to_s == "counters"
|
7
|
+
response = @db_conn.execute("select * from counters where KEY='#{namespace}' and column1 = '#{key}'")
|
8
|
+
response.fetch {|entry| return entry.to_hash["value"]}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Redi2casa
|
2
|
+
def hgetall key, type = "counters"
|
3
|
+
if type.to_s == "counters"
|
4
|
+
response = @db_conn.execute("select * from counters where KEY='#{key}'")
|
5
|
+
hsh = {}
|
6
|
+
response.fetch {|resp| entry = resp.to_hash; hsh[entry["column1"]] = entry["value"] }
|
7
|
+
hsh
|
8
|
+
elsif type.to_s == "sets"
|
9
|
+
resp = @db_conn.execute("select * from sets where namespace = ?", key).fetch
|
10
|
+
resp.nil? ? nil : resp.to_hash['key']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/redi2casa.rb
ADDED
data/redi2casa.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'redi2casa/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "redi2casa"
|
8
|
+
spec.version = Redi2casa::VERSION
|
9
|
+
spec.authors = ["vireshas"]
|
10
|
+
spec.email = ["asviresh@gmail.com"]
|
11
|
+
spec.description = %q{Providing Redis data-structures using Cassandra}
|
12
|
+
spec.summary = %q{Moving redis calls to equivalent cassandra calls can be a pain unless you use this gem}
|
13
|
+
spec.homepage = "https://github.com/vireshas/redi2casa"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redi2casa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- vireshas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Providing Redis data-structures using Cassandra
|
47
|
+
email:
|
48
|
+
- asviresh@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/redi2casa.rb
|
59
|
+
- lib/redi2casa/hget.rb
|
60
|
+
- lib/redi2casa/hgetall.rb
|
61
|
+
- lib/redi2casa/hincrby.rb
|
62
|
+
- lib/redi2casa/hset.rb
|
63
|
+
- lib/redi2casa/version.rb
|
64
|
+
- redi2casa.gemspec
|
65
|
+
homepage: https://github.com/vireshas/redi2casa
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
hash: -342368479
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
hash: -342368479
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.24
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Moving redis calls to equivalent cassandra calls can be a pain unless you
|
96
|
+
use this gem
|
97
|
+
test_files: []
|