joshbuddy-tokyo_cache_cow 0.0.2 → 0.0.3
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/README.rdoc +10 -5
- data/VERSION.yml +1 -1
- data/lib/tokyo_cache_cow/server.rb +32 -1
- data/spec/server_spec.rb +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -68,12 +68,17 @@ But <i>other_key</i> is still peachy.
|
|
68
68
|
|
69
69
|
>> tokyo_cache_cow --help
|
70
70
|
|
71
|
-
--------------
|
72
|
-
|
73
71
|
Usage: tokyo_cache_cow [options]
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
Options:
|
73
|
+
-p, --port[OPTIONAL] Port (default: 11211)
|
74
|
+
-a, --address[OPTIONAL] Address (default: 0.0.0.0)
|
75
|
+
-c, --class[OPTIONAL] Cache provider class (default: TokyoCacheCow::Cache::TokyoCabinetMemcache)
|
76
|
+
-r, --require[OPTIONAL] require
|
77
|
+
-f, --file[OPTIONAL] File (default: /tmp/tcc-cache)
|
78
|
+
-d, --daemonize[OPTIONAL] Daemonize (default: false)
|
79
|
+
-P, --pid[OPTIONAL] Pid file (default: /tmp/tcc.pid)
|
80
|
+
-m, --matcher[OPTIONAL] Special flag for doing matched deletes (not enabled by default)
|
81
|
+
-h, --help Show this help message.
|
77
82
|
|
78
83
|
=== Client
|
79
84
|
|
data/VERSION.yml
CHANGED
@@ -68,8 +68,23 @@ class TokyoCacheCow
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def set_incomplete(ss, length, part)
|
72
|
+
if ss.rest.size < length
|
73
|
+
if @body
|
74
|
+
@body << ss.string
|
75
|
+
else
|
76
|
+
@body = part
|
77
|
+
@body << ss.rest
|
78
|
+
end
|
79
|
+
true
|
80
|
+
else
|
81
|
+
false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
71
85
|
def receive_data(data)
|
72
|
-
ss = StringScanner.new(data)
|
86
|
+
ss = StringScanner.new(@body ? @body << data : data)
|
87
|
+
|
73
88
|
while part = ss.scan_until(TerminatorRegex)
|
74
89
|
begin
|
75
90
|
command_argument_separator_index = part.index(/\s/)
|
@@ -95,32 +110,46 @@ class TokyoCacheCow
|
|
95
110
|
SetCommand.match(args) or (send_client_error and next)
|
96
111
|
(key, flags, expires, bytes, noreply) = [$1, Integer($2), Integer($3), Integer($4), !$5.nil?]
|
97
112
|
next unless validate_key(key)
|
113
|
+
if ss.rest.size < bytes
|
114
|
+
@bytes_left = bytes - ss.rest.size
|
115
|
+
end
|
116
|
+
|
117
|
+
return if set_incomplete(ss, bytes, part)
|
98
118
|
send_data(@cache.set(key, ss.rest[0, bytes.to_i], :flags => flags, :expires => expires) ?
|
99
119
|
StoredReply : NotStoredReply)
|
120
|
+
@body = nil
|
100
121
|
ss.pos += bytes + 2
|
101
122
|
when 'add'
|
102
123
|
SetCommand.match(args)
|
103
124
|
(key, flags, expires, bytes, noreply) = [$1, $2.to_i, $3.to_i, $4, !$5.nil?]
|
125
|
+
return if set_incomplete(ss, bytes, part)
|
104
126
|
send_data(@cache.add(key, ss.rest[0, bytes.to_i], :flags => flags, :expires => expires) ?
|
105
127
|
StoredReply : NotStoredReply)
|
128
|
+
@body = nil
|
106
129
|
ss.pos += bytes + 2
|
107
130
|
when 'replace'
|
108
131
|
SetCommand.match(args)
|
109
132
|
(key, flags, expires, bytes, noreply) = [$1, $2.to_i, $3.to_i, $4, !$5.nil?]
|
133
|
+
return if set_incomplete(ss, bytes, part)
|
110
134
|
send_data(@cache.replace(key, ss.rest[0, bytes.to_i], :flags => flags, :expires => expires) ?
|
111
135
|
StoredReply : NotStoredReply)
|
136
|
+
@body = nil
|
112
137
|
ss.pos += bytes + 2
|
113
138
|
when 'append'
|
114
139
|
SetCommand.match(args)
|
115
140
|
(key, flags, expires, bytes, noreply) = [$1, $2.to_i, $3.to_i, $4, !$5.nil?]
|
141
|
+
return if set_incomplete(ss, bytes, part)
|
116
142
|
send_data(@cache.append(key, ss.rest[0, bytes.to_i], :flags => flags, :expires => expires) ?
|
117
143
|
StoredReply : NotStoredReply)
|
144
|
+
@body = nil
|
118
145
|
ss.pos += bytes + 2
|
119
146
|
when 'prepend'
|
120
147
|
SetCommand.match(args)
|
121
148
|
(key, flags, expires, bytes, noreply) = [$1, $2.to_i, $3.to_i, $4, !$5.nil?]
|
149
|
+
return if set_incomplete(ss, bytes, part)
|
122
150
|
send_data(@cache.prepend(key, ss.rest[0, bytes.to_i], :flags => flags, :expires => expires) ?
|
123
151
|
StoredReply : NotStoredReply)
|
152
|
+
@body = nil
|
124
153
|
ss.pos += bytes + 2
|
125
154
|
when 'cas'
|
126
155
|
# do something
|
@@ -173,6 +202,8 @@ class TokyoCacheCow
|
|
173
202
|
send_data(Error)
|
174
203
|
end
|
175
204
|
rescue
|
205
|
+
puts $!
|
206
|
+
puts $!.backtrace
|
176
207
|
send_server_error($!)
|
177
208
|
end
|
178
209
|
end
|
data/spec/server_spec.rb
CHANGED
@@ -18,8 +18,8 @@ describe 'memcache server' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should get & set" do
|
21
|
-
cache.set('asd', "qweqweasd")
|
22
|
-
cache.get('asd').should == "qweqweasd"
|
21
|
+
cache.set('asd', "qweqweasd" * 2000)
|
22
|
+
cache.get('asd').should == "qweqweasd" * 2000
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should delete" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joshbuddy-tokyo_cache_cow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Hull
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-14 00:00:00 -07:00
|
13
13
|
default_executable: tokyo_cache_cow
|
14
14
|
dependencies: []
|
15
15
|
|