tokyo_cache_cow 0.0.7 → 0.0.8
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/VERSION.yml +2 -2
- data/lib/tokyo_cache_cow/runner.rb +4 -4
- data/lib/tokyo_cache_cow/server.rb +10 -4
- metadata +18 -9
data/VERSION.yml
CHANGED
@@ -60,8 +60,8 @@ class TokyoCacheCow
|
|
60
60
|
options[:pid] = v
|
61
61
|
end
|
62
62
|
|
63
|
-
opts.on("-m[OPTIONAL]", "--matcher", "Special flag for doing matched deletes (not enabled by default)") do |v|
|
64
|
-
options[:
|
63
|
+
opts.on("-m[OPTIONAL]", "--matcher", "Special flag for doing matched deletes and gets (not enabled by default)") do |v|
|
64
|
+
options[:special_match_char] = v
|
65
65
|
end
|
66
66
|
|
67
67
|
opts.on("-M[=OPTIONAL]", "--marshalling", "Disable marshalling of values") do |v|
|
@@ -86,7 +86,7 @@ class TokyoCacheCow
|
|
86
86
|
|
87
87
|
address = @options[:address]
|
88
88
|
port = @options[:port]
|
89
|
-
|
89
|
+
special_match_char = @options[:special_match_char]
|
90
90
|
puts "Starting the tokyo cache cow #{address} #{port}"
|
91
91
|
pid = EM.fork_reactor do
|
92
92
|
cache = clazz.new(:file => @options[:file])
|
@@ -95,7 +95,7 @@ class TokyoCacheCow
|
|
95
95
|
EM.run do
|
96
96
|
EM.start_server(address, port, TokyoCacheCow::Server) do |c|
|
97
97
|
c.cache = cache
|
98
|
-
c.
|
98
|
+
c.special_match_char = special_match_char if special_match_char
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -44,7 +44,7 @@ class TokyoCacheCow
|
|
44
44
|
|
45
45
|
TerminatorRegex = /\r\n/
|
46
46
|
|
47
|
-
attr_accessor :cache, :
|
47
|
+
attr_accessor :cache, :special_match_char
|
48
48
|
|
49
49
|
def send_client_error(message = "invalid arguments")
|
50
50
|
send_data(ClientError % message.to_s)
|
@@ -101,7 +101,13 @@ class TokyoCacheCow
|
|
101
101
|
keys = args.split(/\s+/)
|
102
102
|
keys.each do |k|
|
103
103
|
next unless validate_key(k)
|
104
|
-
if
|
104
|
+
if special_match_char && k.index(special_match_char) == 0
|
105
|
+
k.slice!(0, special_match_char.size)
|
106
|
+
value = @cache.get_match(k).join(' ')
|
107
|
+
send_data(GetValueReply % [k, "0", value.size])
|
108
|
+
send_data(value)
|
109
|
+
send_data(Terminator)
|
110
|
+
elsif k =~ /^(avg|sum|count|min|max)\((.*?)\)$/
|
105
111
|
value = @cache.send(:"#{$1}_match", $2).to_s
|
106
112
|
send_data(GetValueReply % [k, "0", value.size])
|
107
113
|
send_data(value)
|
@@ -173,8 +179,8 @@ class TokyoCacheCow
|
|
173
179
|
when DeleteCommand
|
174
180
|
(key, noreply) = [$1.chomp, !$2.nil?]
|
175
181
|
next unless validate_key(key)
|
176
|
-
if
|
177
|
-
key.slice!(0,
|
182
|
+
if special_match_char && key.index(special_match_char) == 0
|
183
|
+
key.slice!(0,special_match_char.size)
|
178
184
|
@cache.delete_match(key)
|
179
185
|
send_data(DeletedReply)
|
180
186
|
else
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tokyo_cache_cow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
version: 0.0.8
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Joshua Hull
|
@@ -9,19 +14,21 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-30 00:00:00 -04:00
|
13
18
|
default_executable: tokyo_cache_cow
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: eventmachine
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
description: ""
|
26
33
|
email: joshbuddy@gmail.com
|
27
34
|
executables:
|
@@ -60,18 +67,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
67
|
requirements:
|
61
68
|
- - ">="
|
62
69
|
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
63
72
|
version: "0"
|
64
|
-
version:
|
65
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
74
|
requirements:
|
67
75
|
- - ">="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
69
79
|
version: "0"
|
70
|
-
version:
|
71
80
|
requirements: []
|
72
81
|
|
73
82
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.3.
|
83
|
+
rubygems_version: 1.3.6
|
75
84
|
signing_key:
|
76
85
|
specification_version: 3
|
77
86
|
summary: ""
|