redis-ssdb-proxy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0c90d5e791fc969886aff47810874e366c6901b0
4
+ data.tar.gz: 733afdc60d1f238a3c2ae2a420100a5bcd9547c3
5
+ SHA512:
6
+ metadata.gz: de07fcd8e9505a7aedc0f82c5fc77c99fcea9c42fd15e4c4a8cd403b848b1d0591d90c0dac02f5c33099d1d63908b0e10ae51646c0b1447e0fa9737595f3c94a
7
+ data.tar.gz: c0a9893effc69a20cee1ff481fb8f742ad6091d7b496f97dd29799da2cc373b647bb89faddffe8897b9181ed34b00732363f8c0d635d83bf9ee10caaf6d455d1
@@ -0,0 +1,55 @@
1
+ /Gemfile.lock
2
+ /coverage/
3
+ /spec/reports/
4
+
5
+ *.gem
6
+ *.rbc
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /spec/examples.txt
13
+ /test/tmp/
14
+ /test/version_tmp/
15
+ /tmp/
16
+
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ ## Specific to RubyMotion:
21
+ .dat*
22
+ .repl_history
23
+ build/
24
+ *.bridgesupport
25
+ build-iPhoneOS/
26
+ build-iPhoneSimulator/
27
+
28
+ ## Specific to RubyMotion (use of CocoaPods):
29
+ #
30
+ # We recommend against adding the Pods directory to your .gitignore. However
31
+ # you should judge for yourself, the pros and cons are mentioned at:
32
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
33
+ #
34
+ # vendor/Pods/
35
+
36
+ ## Documentation cache and generated files:
37
+ /.yardoc/
38
+ /_yardoc/
39
+ /doc/
40
+ /rdoc/
41
+
42
+ ## Environment normalization:
43
+ /.bundle/
44
+ /vendor/bundle
45
+ /lib/bundler/man/
46
+
47
+ # for a library or gem, you might want to ignore these files since the code is
48
+ # intended to run in multiple environments; otherwise, check them in:
49
+ # Gemfile.lock
50
+ # .ruby-version
51
+ # .ruby-gemset
52
+
53
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
54
+ .rvmrc
55
+ .env
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,14 @@
1
+ # services:
2
+ # - redis-server
3
+
4
+
5
+ language: ruby
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.5
9
+ - 2.2
10
+ - 2.3.0
11
+ script: xvfb-run rspec
12
+ before_install: gem install bundler -v 1.11.2
13
+ services:
14
+ - redis
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redis-ssdb-proxy.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Jason Hou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # RedisSsdbProxy
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/redis/ssdb/proxy`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'redis-ssdb-proxy'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install redis-ssdb-proxy
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/falm/redis-ssdb-proxy.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "redis_ssdb_proxy"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ require 'redis_ssdb_proxy'
@@ -0,0 +1,9 @@
1
+
2
+ Gem.find_files('redis_ssdb_proxy/**/*.rb').each { |file| require file }
3
+
4
+ module RedisSsdbProxy
5
+
6
+ def self.new(*args)
7
+ Client.new(*args)
8
+ end
9
+ end
@@ -0,0 +1,109 @@
1
+
2
+ module RedisSsdbProxy
3
+
4
+ class Client
5
+
6
+ attr_accessor :master, :slave
7
+
8
+ def initialize(args)
9
+ self.master, self.slave = args.fetch(:master), args.fetch(:slave)
10
+ if [:master, :slave].include? args[:ssdb]
11
+ delegate_ssdb_unsupport self.send(args[:ssdb])
12
+ end
13
+ end
14
+
15
+ def delegate_ssdb_unsupport(redis_client)
16
+ redis_client.instance_eval do
17
+ def sadd(key, *args)
18
+ zadd(key, args.map{ |arg|
19
+ [Time.now.to_i, arg]
20
+ })
21
+ end
22
+
23
+ def srem(*args)
24
+ zrem(*args)
25
+ end
26
+ end
27
+ end
28
+
29
+ class << self
30
+ private
31
+ def send_to_slave(command)
32
+ class_eval <<-EOS
33
+ def #{command}(*args, &block)
34
+ slave.#{command}(*args, &block)
35
+ end
36
+ EOS
37
+ end
38
+
39
+ def send_to_master(command)
40
+ class_eval <<-EOS
41
+ def #{command}(*args, &block)
42
+ master.#{command}(*args, &block)
43
+ end
44
+ EOS
45
+ end
46
+
47
+ def send_to_both(command)
48
+ class_eval <<-EOS
49
+ def #{command}(*args, &block)
50
+ slave.#{command}(*args, &block)
51
+ master.#{command}(*args, &block)
52
+ end
53
+ EOS
54
+ end
55
+ end
56
+
57
+
58
+ send_to_master :dbsize
59
+ send_to_master :exists
60
+ send_to_master :get
61
+ send_to_master :getbit
62
+ send_to_master :getrange
63
+ send_to_master :hexists
64
+ send_to_master :hget
65
+ send_to_master :hgetall
66
+ send_to_master :hkeys
67
+ send_to_master :hlen
68
+ send_to_master :hmget
69
+ send_to_master :hvals
70
+ send_to_master :keys
71
+ send_to_master :lindex
72
+ send_to_master :llen
73
+ send_to_master :lrange
74
+ send_to_master :mget
75
+ send_to_master :randomkey
76
+ send_to_master :scard
77
+ send_to_master :sdiff
78
+ send_to_master :sinter
79
+ send_to_master :sismember
80
+ send_to_master :smembers
81
+ send_to_master :sort
82
+ send_to_master :srandmember
83
+ send_to_master :strlen
84
+ send_to_master :sunion
85
+ send_to_master :ttl
86
+ send_to_master :type
87
+ send_to_master :zcard
88
+ send_to_master :zcount
89
+ send_to_master :zrange
90
+ send_to_master :zrangebyscore
91
+ send_to_master :zrank
92
+ send_to_master :zrevrange
93
+ send_to_master :zscore
94
+
95
+ # all write opreate send to master slave both
96
+ def method_missing(name, *args, &block)
97
+ if master.respond_to?(name)
98
+ self.class.send(:send_to_both, name)
99
+ slave.send(name, *args, &block)
100
+ master.send(name, *args, &block)
101
+ else
102
+ super
103
+ end
104
+ end
105
+
106
+
107
+ end # Client
108
+
109
+ end # RedisSsdbProxy
@@ -0,0 +1,3 @@
1
+ module RedisSsdbProxy
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'redis_ssdb_proxy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "redis-ssdb-proxy"
8
+ spec.version = RedisSsdbProxy::VERSION
9
+ spec.authors = ["falm"]
10
+ spec.email = ["hjj1992@gmail.com"]
11
+
12
+ spec.summary = %q{proxy that read from redis(or ssdb) write to both use for redis <=> ssdb migration on production}
13
+ spec.description = %q{proxy that read from redis(or ssdb) write to both use for redis <=> ssdb migration on production}
14
+ spec.homepage = "https://github.com/falm/redis-ssdb-proxy"
15
+
16
+ spec.licenses = ["MIT"]
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'redis'
27
+ spec.add_development_dependency 'redis-namespace'
28
+ spec.add_development_dependency 'dotenv'
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redis-ssdb-proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - falm
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: redis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: redis-namespace
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: dotenv
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: proxy that read from redis(or ssdb) write to both use for redis <=> ssdb
98
+ migration on production
99
+ email:
100
+ - hjj1992@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - lib/redis-ssdb-proxy.rb
115
+ - lib/redis_ssdb_proxy.rb
116
+ - lib/redis_ssdb_proxy/client.rb
117
+ - lib/redis_ssdb_proxy/version.rb
118
+ - redis-ssdb-proxy.gemspec
119
+ homepage: https://github.com/falm/redis-ssdb-proxy
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.3
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: proxy that read from redis(or ssdb) write to both use for redis <=> ssdb
143
+ migration on production
144
+ test_files: []