kyototycoon-client 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +9 -0
- data/lib/kyototycoon/client.rb +1 -1
- data/lib/kyototycoon/client/connection.rb +4 -3
- data/lib/kyototycoon/client/version.rb +1 -1
- data/test/kyototycoon/client/test_client.rb +9 -8
- data/test/lua/echo.lua +12 -0
- metadata +14 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f7e73da497ce6d2c925987e974083238447360b5
|
4
|
+
data.tar.gz: a9f89abc3fdf1998926a2e8a8e62ad9c86cdc3f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8654438189056f4f5f7bc2080c7bb36fdd05b66487abe6c8d4b7c4d25b9c4c93830cf7b19204f251fb860c0d096179ce530063294b2023081c5420e74a706d7
|
7
|
+
data.tar.gz: 94bae80a1a18b9bd7fe5ccbd8ec0992e89f89f76b193f3b5da9ea8505794bcae6dd1e2a501a1586a15c98c31a2a6354d5c266f8cb287719adc775eb284bc5421
|
data/README.md
CHANGED
@@ -5,6 +5,10 @@ KyotoTycoon ruby client with TCP connection and binary protocol.
|
|
5
5
|
## Changelog
|
6
6
|
|
7
7
|
* 0.0.2: Add dbid parameter to remove_bulk
|
8
|
+
* 0.0.3: Do nothing if record is empty
|
9
|
+
* 0.0.4: Support multibyte characters
|
10
|
+
* 0.0.5: Fixed empty key bug
|
11
|
+
* 0.0.6: Fixed script protocol bug
|
8
12
|
|
9
13
|
|
10
14
|
## Installation
|
@@ -75,3 +79,8 @@ Client receives response as key-value set format.
|
|
75
79
|
=> {"keyX" => "valueX", "keyY" => "valueY", ... }
|
76
80
|
|
77
81
|
Number of key sent and number of key received are depend on LUA function definition.
|
82
|
+
|
83
|
+
You can test script protocol as below:
|
84
|
+
|
85
|
+
ktserver -port [your port] -scr test/lua/echo.lua
|
86
|
+
rake test HOST=localhost PORT=[your port] SCRIPT=1
|
data/lib/kyototycoon/client.rb
CHANGED
@@ -84,7 +84,7 @@ module Kyototycoon
|
|
84
84
|
keyvalues.each do |k, v|
|
85
85
|
records.push(Record.new(k, v))
|
86
86
|
end
|
87
|
-
results = @connection.script(records)
|
87
|
+
results = @connection.script(method, records)
|
88
88
|
return {} if results == nil
|
89
89
|
results.inject({}) {|map, rec| map[rec.key] = rec.value; map;}
|
90
90
|
end
|
@@ -95,9 +95,10 @@ module Kyototycoon
|
|
95
95
|
count.to_i # number of registerd
|
96
96
|
end
|
97
97
|
|
98
|
-
def script(records)
|
99
|
-
header_entries = [Magic::PLAY_SCRIPT, Flag::RESERVED, records.length]
|
100
|
-
request = header_entries.pack("
|
98
|
+
def script(method, records)
|
99
|
+
header_entries = [Magic::PLAY_SCRIPT, Flag::RESERVED, method.length, records.length]
|
100
|
+
request = header_entries.pack("CNNN")
|
101
|
+
request << method.dup.force_encoding("binary")
|
101
102
|
|
102
103
|
records.each do |r|
|
103
104
|
k = r.key.dup.force_encoding("binary")
|
@@ -147,14 +147,15 @@ class ClientTest < Test::Unit::TestCase
|
|
147
147
|
end
|
148
148
|
|
149
149
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
150
|
+
def test_script
|
151
|
+
return unless ENV["SCRIPT"].to_i == 1
|
152
|
+
return unless @client
|
153
|
+
|
154
|
+
@client.open
|
155
|
+
assert_equal( @client.script("echo", "key", "value"), {"key" => "value"} )
|
156
|
+
assert_equal( @client.script_bulk("echo", {"key" => "value", "foo" => "bar"}), {"key" => "value", "foo" => "bar"} )
|
157
|
+
@client.close
|
158
|
+
end
|
158
159
|
end
|
159
160
|
|
160
161
|
class MockConnection
|
data/test/lua/echo.lua
ADDED
metadata
CHANGED
@@ -1,46 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kyototycoon-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- imasho
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: KyotoTycoon binary access module, supports get(bulk), set(bulk), remove(bulk),
|
@@ -51,7 +46,7 @@ executables: []
|
|
51
46
|
extensions: []
|
52
47
|
extra_rdoc_files: []
|
53
48
|
files:
|
54
|
-
- .gitignore
|
49
|
+
- ".gitignore"
|
55
50
|
- Gemfile
|
56
51
|
- LICENSE.txt
|
57
52
|
- README.md
|
@@ -66,32 +61,33 @@ files:
|
|
66
61
|
- test/benchmark.rb
|
67
62
|
- test/helper.rb
|
68
63
|
- test/kyototycoon/client/test_client.rb
|
64
|
+
- test/lua/echo.lua
|
69
65
|
homepage: ''
|
70
66
|
licenses:
|
71
67
|
- MIT
|
68
|
+
metadata: {}
|
72
69
|
post_install_message:
|
73
70
|
rdoc_options: []
|
74
71
|
require_paths:
|
75
72
|
- lib
|
76
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
74
|
requirements:
|
79
|
-
- -
|
75
|
+
- - ">="
|
80
76
|
- !ruby/object:Gem::Version
|
81
77
|
version: '0'
|
82
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
79
|
requirements:
|
85
|
-
- -
|
80
|
+
- - ">="
|
86
81
|
- !ruby/object:Gem::Version
|
87
82
|
version: '0'
|
88
83
|
requirements: []
|
89
84
|
rubyforge_project:
|
90
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.2.2
|
91
86
|
signing_key:
|
92
|
-
specification_version:
|
87
|
+
specification_version: 4
|
93
88
|
summary: KyotoTycoon binary access module
|
94
89
|
test_files:
|
95
90
|
- test/benchmark.rb
|
96
91
|
- test/helper.rb
|
97
92
|
- test/kyototycoon/client/test_client.rb
|
93
|
+
- test/lua/echo.lua
|