glimpse-dalli 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 1.0.0
2
+
3
+ - Initial release.
4
+
5
+ # 1.1.0
6
+
7
+ - Query count and Query time are now threadsafe.
@@ -17,5 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ['lib']
19
19
 
20
+ gem.add_dependency 'glimpse'
20
21
  gem.add_dependency 'dalli'
22
+ gem.add_dependency 'atomic', '>= 1.0.0'
21
23
  end
@@ -1,5 +1,5 @@
1
1
  module Glimpse
2
2
  module Dalli
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -1,19 +1,26 @@
1
+ require 'atomic'
2
+
1
3
  module Glimpse
2
4
  module Views
3
5
  class Dalli < View
4
6
  def initialize(options = {})
5
- @duration = 0
6
- @calls = 0
7
+ @duration = Atomic.new(0)
8
+ @calls = Atomic.new(0)
7
9
 
8
10
  setup_subscribers
9
11
  end
10
12
 
11
13
  def formatted_duration
12
- "%.2fms" % (@duration * 1000)
14
+ ms = @duration.value * 1000
15
+ if ms >= 1000
16
+ "%.2fms" % ms
17
+ else
18
+ "%.0fms" % ms
19
+ end
13
20
  end
14
21
 
15
22
  def results
16
- { :duration => formatted_duration, :calls => @calls }
23
+ { :duration => formatted_duration, :calls => @calls.value }
17
24
  end
18
25
 
19
26
  private
@@ -21,13 +28,14 @@ module Glimpse
21
28
  def setup_subscribers
22
29
  # Reset each counter when a new request starts
23
30
  before_request do
24
- @duration = 0
25
- @calls = 0
31
+ @duration.value = 0
32
+ @calls.value = 0
26
33
  end
27
34
 
28
35
  subscribe(/cache_(.*).active_support/) do |name, start, finish, id, payload|
29
- @duration += (finish - start)
30
- @calls += 1
36
+ duration = (finish - start)
37
+ @duration.update { |value| value + duration }
38
+ @calls.update { |value| value + 1 }
31
39
  end
32
40
  end
33
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimpse-dalli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-10 00:00:00.000000000 Z
12
+ date: 2013-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: glimpse
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: dalli
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -27,6 +43,22 @@ dependencies:
27
43
  - - ! '>='
28
44
  - !ruby/object:Gem::Version
29
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: atomic
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
30
62
  description: Provide a glimpse into the Memcache commands made through Dalli during
31
63
  your application's requests.
32
64
  email:
@@ -36,6 +68,7 @@ extensions: []
36
68
  extra_rdoc_files: []
37
69
  files:
38
70
  - .gitignore
71
+ - CHANGELOG.md
39
72
  - Gemfile
40
73
  - LICENSE.txt
41
74
  - README.md