binary42-remix-stash 0.9.0 → 0.9.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.
- data/README.mdown +1 -1
- data/VERSION +1 -1
- data/lib/remix/stash/cluster.rb +20 -8
- data/lib/remix/stash.rb +4 -4
- data/remix-stash.gemspec +2 -2
- data/spec/stash_spec.rb +5 -4
- metadata +2 -2
data/README.mdown
CHANGED
@@ -8,7 +8,6 @@ It does require memcached 1.4+ but you should be running that anyway (if you are
|
|
8
8
|
|
9
9
|
# TODO
|
10
10
|
|
11
|
-
* clear on root should do it for each host in a cluster
|
12
11
|
* optimize option merging with cache
|
13
12
|
* make clusters selectable per stash
|
14
13
|
* implement the rest of the memcached 1.4 binary API
|
@@ -16,3 +15,4 @@ It does require memcached 1.4+ but you should be running that anyway (if you are
|
|
16
15
|
* failsafe marshal load
|
17
16
|
* support non-marshal value dumps configured per stash
|
18
17
|
* support intersected stashes with joined vector sets
|
18
|
+
* add jruby specific cluster implementations to work around the lack socket timeouts
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.1
|
data/lib/remix/stash/cluster.rb
CHANGED
@@ -45,14 +45,26 @@ class Stash::Cluster
|
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
48
|
+
if RUBY_PLATFORM =~ /java/
|
49
|
+
|
50
|
+
def connect(host, port)
|
51
|
+
# We currently don't support timeouts in JRuby since the socket API is
|
52
|
+
# incomplete.
|
53
|
+
TCPSocket.new(host, port)
|
54
|
+
end
|
55
|
+
|
56
|
+
else
|
57
|
+
|
58
|
+
def connect(host, port)
|
59
|
+
address = Socket.getaddrinfo(host, nil).first
|
60
|
+
socket = Socket.new(Socket.const_get(address[0]), SOCK_STREAM, 0)
|
61
|
+
timeout = [2,0].pack('l_2') # 2 seconds
|
62
|
+
socket.setsockopt(SOL_SOCKET, SO_SNDTIMEO, timeout)
|
63
|
+
socket.setsockopt(SOL_SOCKET, SO_RCVTIMEO, timeout)
|
64
|
+
socket.connect(Socket.pack_sockaddr_in(port, address[3]))
|
65
|
+
socket
|
66
|
+
end
|
67
|
+
|
56
68
|
end
|
57
69
|
|
58
70
|
def host_to_io(key, host, port)
|
data/lib/remix/stash.rb
CHANGED
@@ -74,7 +74,7 @@ class Stash
|
|
74
74
|
[:dynamic, :action, :transaction].include?(opts[:coherency]) or raise ArgumentError,
|
75
75
|
"Invalid coherency setting used (#{opts[:coherency].inspect})"
|
76
76
|
end
|
77
|
-
root = @@instances[:
|
77
|
+
root = @@instances[:root] || Stash.new(:root)
|
78
78
|
self == root ?
|
79
79
|
base :
|
80
80
|
root.default.merge(base)
|
@@ -102,9 +102,9 @@ class Stash
|
|
102
102
|
key = canonical_key(keys)
|
103
103
|
cluster.select(key) {|io|
|
104
104
|
if Protocol.get(io, key)
|
105
|
+
yield(*keys)
|
105
106
|
true
|
106
107
|
else
|
107
|
-
yield(*keys)
|
108
108
|
false
|
109
109
|
end
|
110
110
|
}
|
@@ -160,7 +160,7 @@ class Stash
|
|
160
160
|
private
|
161
161
|
|
162
162
|
def canonical_key(keys)
|
163
|
-
"#{implicit_scope}#{keys.join('/')}
|
163
|
+
"#{implicit_scope}#{keys.join('/')}#{vector}"
|
164
164
|
end
|
165
165
|
|
166
166
|
def cluster
|
@@ -194,7 +194,7 @@ private
|
|
194
194
|
Protocol.add(io, vk, '0')
|
195
195
|
@vector = Protocol.get(io, vk)
|
196
196
|
end
|
197
|
-
@vector
|
197
|
+
@vector = "@#@name:#@vector"
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
data/remix-stash.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{remix-stash}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Mitchell"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-09-02}
|
13
13
|
s.email = %q{binary42@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
data/spec/stash_spec.rb
CHANGED
@@ -249,17 +249,17 @@ class StashSpec < Spec
|
|
249
249
|
|
250
250
|
context '#gate' do
|
251
251
|
|
252
|
-
should 'evaluate on a key miss' do
|
252
|
+
should 'not evaluate on a key miss' do
|
253
253
|
ran = false
|
254
254
|
stash.gate(:k) {ran = true}
|
255
|
-
assert ran
|
255
|
+
assert !ran
|
256
256
|
end
|
257
257
|
|
258
|
-
should '
|
258
|
+
should 'evaluate on a key hit' do
|
259
259
|
ran = false
|
260
260
|
stash[:k] = :hit
|
261
261
|
stash.gate(:k) {ran = true}
|
262
|
-
assert
|
262
|
+
assert ran
|
263
263
|
end
|
264
264
|
|
265
265
|
should 'return true on hit' do
|
@@ -273,6 +273,7 @@ class StashSpec < Spec
|
|
273
273
|
|
274
274
|
should 'pass keys in as optional block arguments' do
|
275
275
|
key = nil
|
276
|
+
stash[42] = true
|
276
277
|
stash.gate(42) {|k| key = k}
|
277
278
|
assert_equal 42, key
|
278
279
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binary42-remix-stash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Mitchell
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|