dalli-extra 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +32 -15
- data/LICENSE +22 -0
- data/README.md +3 -2
- data/dalli-extra.gemspec +2 -2
- data/lib/dalli/extra.rb +20 -0
- data/lib/dalli/extra/version.rb +1 -1
- data/spec/dalli-extra_spec.rb +54 -0
- metadata +8 -7
- data/LICENSE.txt +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
|
4
|
-
|
3
|
+
metadata.gz: 601a66a0b25c07ff342f91cafde9a180daa61559
|
4
|
+
data.tar.gz: 47dd6ec06bcc2010393c6e64448ad1a60f1e42ea
|
5
5
|
SHA512:
|
6
|
-
|
7
|
-
|
6
|
+
metadata.gz: 8a7e0e41cd1e6169fd2f9c0e944812fa639f5b69944ddd86ad97f186ba8567880c58185a0264e738cefb5cc03778381b41cf68561054d922af84b1cb255b6e7d
|
7
|
+
data.tar.gz: 7076b93383b0303259e4b1bdb45f44e71531e1bd149ddb558ccc68f4ef6490ae26b342dcb163c06a611af0c2ab721a66322e94d5ecab64a891fe359a90e7bbc3
|
data/.gitignore
CHANGED
@@ -1,17 +1,34 @@
|
|
1
1
|
*.gem
|
2
2
|
*.rbc
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Sumit Maheshwari
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
CHANGED
@@ -21,9 +21,8 @@ Or install it yourself as:
|
|
21
21
|
$ gem install dalli-extra
|
22
22
|
|
23
23
|
## Usage
|
24
|
-
```ruby
|
25
24
|
require 'dalli'
|
26
|
-
require 'dalli
|
25
|
+
require 'dalli/extra'
|
27
26
|
dc = Dalli::Client.new(['localhost:11211','localhost:11212'], :expires_in => 300)
|
28
27
|
|
29
28
|
all_keys = dc.keys
|
@@ -36,6 +35,8 @@ Or install it yourself as:
|
|
36
35
|
|
37
36
|
count = dc.delete_matched(/abc/) or
|
38
37
|
count = dc.delete_macthed('abc')
|
38
|
+
|
39
|
+
stats = dc.cluster_stats
|
39
40
|
|
40
41
|
## Contributing
|
41
42
|
|
data/dalli-extra.gemspec
CHANGED
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "dalli-extra"
|
8
8
|
spec.version = Dalli::Extra::VERSION
|
9
9
|
spec.authors = ["Sumit Maheshwari"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["sumeet.manit@gmail.com"]
|
11
11
|
spec.description = 'Adding some extra methods to Dalli'
|
12
12
|
spec.summary = 'Adding some extra methods to Dalli'
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/msumit/dalli-extra"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/dalli/extra.rb
CHANGED
@@ -59,6 +59,26 @@ module Dalli
|
|
59
59
|
_keys.map{|k| delete(k)}.reject{|y| !y}.count
|
60
60
|
end
|
61
61
|
|
62
|
+
# Returns a Hash representing sum of stats of each server in ring.
|
63
|
+
def cluster_stats(type=nil)
|
64
|
+
hash = {'cluster_size' => @servers.length, 'active_servers' => 0}
|
65
|
+
ignore = ['accepting_conns', 'pointer_size', 'version', 'pid', 'time']
|
66
|
+
stats(type).each do |key,val|
|
67
|
+
unless val.nil?
|
68
|
+
hash['active_servers'] += 1
|
69
|
+
val.each do |k,v|
|
70
|
+
next if ignore.include?(k)
|
71
|
+
if hash.has_key?(k)
|
72
|
+
hash[k] += v.match('\.').nil? ? Integer(v) : Float(v) rescue v
|
73
|
+
else
|
74
|
+
hash[k] = v.match('\.').nil? ? Integer(v) : Float(v) rescue v
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
hash
|
80
|
+
end
|
81
|
+
|
62
82
|
private
|
63
83
|
|
64
84
|
def telnet(server)
|
data/lib/dalli/extra/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'dalli'
|
3
|
+
require 'dalli/extra'
|
4
|
+
|
5
|
+
describe 'dalli-extra' do
|
6
|
+
|
7
|
+
subject(:dc) { Dalli::Client.new(['localhost:11211','localhost:11212'], :expires_in => 300) }
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
dc.set('dalli-extra-abc', 123)
|
11
|
+
dc.set('dalli-extra-abcd', 1234)
|
12
|
+
dc.set('dalli-extra-xyz', 123)
|
13
|
+
end
|
14
|
+
|
15
|
+
it {should respond_to(:keys)}
|
16
|
+
it {should respond_to(:pairs)}
|
17
|
+
it {should respond_to(:delete_matched)}
|
18
|
+
it {should respond_to(:cluster_stats)}
|
19
|
+
|
20
|
+
|
21
|
+
it 'should get all keys' do
|
22
|
+
keys = dc.keys
|
23
|
+
keys.should_not be(nil)
|
24
|
+
keys.size.should >= 3
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should get all key-value pairs' do
|
28
|
+
pairs = dc.pairs
|
29
|
+
pairs.should_not be(nil)
|
30
|
+
pairs.size.should >= 3
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should get keys which matches the regexp' do
|
34
|
+
keys = dc.keys(/dalli-extra-abc/)
|
35
|
+
keys.should_not be(nil)
|
36
|
+
keys.size.should be 2
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should get kay-value pairs which matches the regexp' do
|
40
|
+
pairs = dc.pairs(/dalli-extra-abc/)
|
41
|
+
pairs.should_not be(nil)
|
42
|
+
pairs.size.should be 2
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should delete matched keys' do
|
46
|
+
dc.delete_matched(/dalli-extra/).should be 3
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should return a hash with cluster stats' do
|
50
|
+
stats = dc.cluster_stats
|
51
|
+
stats.should_not be(nil)
|
52
|
+
stats.should be_a(Hash)
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dalli-extra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sumit Maheshwari
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-27 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version_requirements: *id003
|
45
45
|
description: Adding some extra methods to Dalli
|
46
46
|
email:
|
47
|
-
-
|
47
|
+
- sumeet.manit@gmail.com
|
48
48
|
executables: []
|
49
49
|
|
50
50
|
extensions: []
|
@@ -54,13 +54,14 @@ extra_rdoc_files: []
|
|
54
54
|
files:
|
55
55
|
- .gitignore
|
56
56
|
- Gemfile
|
57
|
-
- LICENSE
|
57
|
+
- LICENSE
|
58
58
|
- README.md
|
59
59
|
- Rakefile
|
60
60
|
- dalli-extra.gemspec
|
61
61
|
- lib/dalli/extra.rb
|
62
62
|
- lib/dalli/extra/version.rb
|
63
|
-
|
63
|
+
- spec/dalli-extra_spec.rb
|
64
|
+
homepage: https://github.com/msumit/dalli-extra
|
64
65
|
licenses:
|
65
66
|
- MIT
|
66
67
|
metadata: {}
|
@@ -83,5 +84,5 @@ rubygems_version: 2.1.7
|
|
83
84
|
signing_key:
|
84
85
|
specification_version: 4
|
85
86
|
summary: Adding some extra methods to Dalli
|
86
|
-
test_files:
|
87
|
-
|
87
|
+
test_files:
|
88
|
+
- spec/dalli-extra_spec.rb
|
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Sumit Maheshwari
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|