dallish 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -7
- data/lib/dallish.rb +2 -1
- data/lib/dallish/client.rb +7 -10
- data/lib/dallish/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
<<<<<<< HEAD
|
2
|
-
dallish
|
3
|
-
=======
|
4
|
-
|
5
|
-
An extended Dalli for memcached 1.4.x
|
6
|
-
=======
|
7
1
|
# Dallish
|
8
2
|
|
9
3
|
Dallish is an extended [Dalli](https://github.com/mperham/dalli) for memcached 1.4.x.
|
@@ -50,4 +44,4 @@ dallish.delete_all_by(/foo.+/)
|
|
50
44
|
## License
|
51
45
|
|
52
46
|
The MIT License
|
53
|
-
|
47
|
+
|
data/lib/dallish.rb
CHANGED
@@ -18,7 +18,8 @@ module Dallish
|
|
18
18
|
|
19
19
|
def self.is_the_arg_dalli_servers(params_or_dalli_servers)
|
20
20
|
params_or_dalli_servers and
|
21
|
-
|
21
|
+
(params_or_dalli_servers.is_a?(String) or
|
22
|
+
params_or_dalli_servers.is_a?(Array))
|
22
23
|
end
|
23
24
|
|
24
25
|
end
|
data/lib/dallish/client.rb
CHANGED
@@ -27,7 +27,7 @@ module Dallish
|
|
27
27
|
|
28
28
|
# cannot support memcached 1.6 or higher
|
29
29
|
self.servers.each { |server|
|
30
|
-
version =
|
30
|
+
version = telnet_connect(server, :prompt => /\n/).cmd('version')
|
31
31
|
self.log.debug "version: #{version}"
|
32
32
|
|
33
33
|
/VERSION (?<major_version>\d+\.\d+).*/ =~ version
|
@@ -37,10 +37,10 @@ module Dallish
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def telnet_connect(server, options = {})
|
41
41
|
(host, port) = server.split(':')
|
42
42
|
self.log.debug "target memcahced server: #{host}:#{port}"
|
43
|
-
|
43
|
+
Net::Telnet::new(
|
44
44
|
'Host' => host,
|
45
45
|
'Port' => port,
|
46
46
|
'Prompt' => options[:prompt] || /(^END$)/,
|
@@ -50,7 +50,7 @@ module Dallish
|
|
50
50
|
|
51
51
|
def all_keys()
|
52
52
|
self.servers.flat_map { |server|
|
53
|
-
telnet =
|
53
|
+
telnet = telnet_connect(server)
|
54
54
|
begin
|
55
55
|
slab_ids = telnet.cmd("stats slabs").split("\n").map { |line|
|
56
56
|
/STAT (?<slab_id>\d+):.+/ =~ line
|
@@ -58,7 +58,7 @@ module Dallish
|
|
58
58
|
}.reject { |e| e.nil? }.uniq
|
59
59
|
|
60
60
|
slab_ids.flat_map { |slab_id|
|
61
|
-
telnet.cmd("stats cachedump #{slab_id}
|
61
|
+
telnet.cmd("stats cachedump #{slab_id} 10000000").split("\n").map { |line|
|
62
62
|
/ITEM (?<key>.+) \[\d+ b; \d+ s\]/ =~ line
|
63
63
|
key
|
64
64
|
}
|
@@ -73,17 +73,14 @@ module Dallish
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def find_keys_by(regexp)
|
76
|
-
all_keys.select { |key|
|
77
|
-
if key.is_a?(Array) then
|
78
|
-
puts "#{key},#{key.class}"
|
79
|
-
end
|
80
|
-
regexp.match(key) }
|
76
|
+
all_keys.select { |key| regexp.match(key) }
|
81
77
|
end
|
82
78
|
|
83
79
|
def delete_all_by(regexp)
|
84
80
|
find_keys_by(regexp).each do |key|
|
85
81
|
self.dalli.delete(key)
|
86
82
|
end
|
83
|
+
nil
|
87
84
|
end
|
88
85
|
|
89
86
|
def find_all_by(regexp)
|
data/lib/dallish/version.rb
CHANGED