sohm 0.10.0 → 0.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2d4f419606a66335e7a44d8440732b4179a068f
4
- data.tar.gz: 6565464772af7ad624fb92268cac9ede60f70b44
3
+ metadata.gz: 859ccb91894c9f987316960595b6fe50084b5755
4
+ data.tar.gz: 4fddfad5a05999a99dc46fc65df4e36405ef582e
5
5
  SHA512:
6
- metadata.gz: 6336ecb58d5112f896f673730c58b9810731342bf88183bebae05cef484a7eb377a9ffff95978211122889d6be61d0820bebc2d6c134d8c97a007e9e501aaf3d
7
- data.tar.gz: f6c0592a5f52e04352121bc9975b30b45ac13c6e677a4b27a43f1032df8bc1c92aa1123d83e03ca7f41a269c02bd50679e44e675df8f54bdc1619cee2f9cb370
6
+ metadata.gz: 219278de40db8ec365bc2fbfe553bcda87dd08407c200e6ad200f0d3b66ed94d24a67ca4baf8f5a04e4a3c25ea473c23eda6530b4d9ad048ff36bc15ec7a8993
7
+ data.tar.gz: dfbd6ab50d8e91b0eb77ccff049d93fdb063a16b71e76477366ae5754789040d8fe94f7bf672024d6feb725087e574b92577e456b3bc53d1d1e5804e6fadc219
data/lib/sohm.rb CHANGED
@@ -6,7 +6,6 @@ require "nido"
6
6
  require "redic"
7
7
  require "securerandom"
8
8
  require "set"
9
- require_relative "sohm/command"
10
9
 
11
10
  module Sohm
12
11
  LUA_SAVE = File.read(File.expand_path("../sohm/lua/save.lua", __FILE__))
data/sohm.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "sohm"
3
- s.version = "0.10.0"
3
+ s.version = "0.10.1"
4
4
  s.summary = %{Slim ohm for twemproxy-like system}
5
5
  s.description = %Q{Slim ohm is a forked ohm that works with twemproxy-like redis system, only a limited set of features in ohm is supported}
6
6
  s.authors = ["Xuejie Xiao"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sohm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xuejie Xiao
@@ -83,14 +83,12 @@ files:
83
83
  - README.md
84
84
  - lib/sohm.rb
85
85
  - lib/sohm/auto_id.rb
86
- - lib/sohm/command.rb
87
86
  - lib/sohm/index_all.rb
88
87
  - lib/sohm/json.rb
89
88
  - lib/sohm/lua/save.lua
90
89
  - makefile
91
90
  - sohm.gemspec
92
91
  - test/association.rb
93
- - test/command.rb
94
92
  - test/connection.rb
95
93
  - test/core.rb
96
94
  - test/counters.rb
data/lib/sohm/command.rb DELETED
@@ -1,51 +0,0 @@
1
- module Sohm
2
- class Command
3
- def self.[](operation, head, *tail)
4
- return head if tail.empty?
5
-
6
- new(operation, head, *tail)
7
- end
8
-
9
- attr :operation
10
- attr :args
11
- attr :keys
12
-
13
- def initialize(operation, *args)
14
- @operation = operation
15
- @args = args
16
- @keys = []
17
- end
18
-
19
- def call(nido, redis)
20
- newkey(nido, redis) do |key|
21
- redis.call(@operation, key, *params(nido, redis))
22
- end
23
- end
24
-
25
- def clean
26
- keys.each do |key, redis|
27
- redis.call("DEL", key)
28
- end
29
-
30
- subcommands.each { |cmd| cmd.clean }
31
- end
32
-
33
- private
34
- def subcommands
35
- args.select { |arg| arg.respond_to?(:call) }
36
- end
37
-
38
- def params(nido, redis)
39
- args.map { |arg| arg.respond_to?(:call) ? arg.call(nido, redis) : arg }
40
- end
41
-
42
- def newkey(nido, redis)
43
- key = nido[SecureRandom.hex(32)]
44
- keys << [key, redis]
45
-
46
- yield key
47
-
48
- return key
49
- end
50
- end
51
- end
data/test/command.rb DELETED
@@ -1,55 +0,0 @@
1
- require_relative "helper"
2
-
3
- scope do
4
- setup do
5
- redis = Redic.new
6
- redis.call("FLUSHDB")
7
-
8
- nido = Nido.new("User:tmp")
9
-
10
- [1, 2, 3].each { |i| redis.call("SADD", "A", i) }
11
- [1, 4, 5].each { |i| redis.call("SADD", "B", i) }
12
-
13
- [10, 11, 12].each { |i| redis.call("SADD", "C", i) }
14
- [11, 12, 13].each { |i| redis.call("SADD", "D", i) }
15
- [12, 13, 14].each { |i| redis.call("SADD", "E", i) }
16
-
17
- [10, 11, 12].each { |i| redis.call("SADD", "F", i) }
18
- [11, 12, 13].each { |i| redis.call("SADD", "G", i) }
19
- [12, 13, 14].each { |i| redis.call("SADD", "H", i) }
20
-
21
- [redis, nido]
22
- end
23
-
24
- test "special condition: single argument returns that arg" do
25
- assert_equal "A", Sohm::Command[:sinterstore, "A"]
26
- end
27
-
28
- test "full stack test" do |redis, nido|
29
- cmd1 = Sohm::Command[:sinterstore, "A", "B"]
30
-
31
- res = cmd1.call(nido, redis)
32
- assert_equal ["1"], redis.call("SMEMBERS", res)
33
-
34
- cmd1.clean
35
- assert_equal 0, redis.call("EXISTS", res)
36
-
37
- cmd2 = Sohm::Command[:sinterstore, "C", "D", "E"]
38
- cmd3 = Sohm::Command[:sunionstore, cmd1, cmd2]
39
-
40
- res = cmd3.call(nido, redis)
41
- assert_equal ["1", "12"], redis.call("SMEMBERS", res)
42
-
43
- cmd3.clean
44
- assert redis.call("KEYS", nido["*"]).empty?
45
-
46
- cmd4 = Sohm::Command[:sinterstore, "F", "G", "H"]
47
- cmd5 = Sohm::Command[:sdiffstore, cmd3, cmd4]
48
-
49
- res = cmd5.call(nido, redis)
50
- assert_equal ["1"], redis.call("SMEMBERS", res)
51
-
52
- cmd5.clean
53
- assert redis.call("KEYS", nido["*"]).empty?
54
- end
55
- end