lockistics 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/lockistics/lock.rb +0 -1
- data/lib/lockistics/meter.rb +2 -2
- data/lib/lockistics/version.rb +1 -1
- data/spec/meter_spec.rb +2 -1
- data/spec/spec_helper.rb +4 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -172,6 +172,8 @@ You can query statistics for locking/metering keys.
|
|
172
172
|
- namespace.KEY_NAME.total has all time stats for the key
|
173
173
|
- namespace.known_keys is a sorted set of known keys
|
174
174
|
|
175
|
+
Storage amount requirements are not that large since there's only incremental/min_max counters maximum once for each hour, each day and the total. My guess is max 10kb per day per key, so even with actions to a million keys a day you would still have inrease of maybe 10 megabytes a day. In a future version there can be an option to set expiration on darily/hourly hashes so that old data disappears automatically.
|
176
|
+
|
175
177
|
## Contributing
|
176
178
|
|
177
179
|
1. Fork it
|
data/lib/lockistics/lock.rb
CHANGED
data/lib/lockistics/meter.rb
CHANGED
@@ -52,7 +52,7 @@ module Lockistics
|
|
52
52
|
yield DummyMeter.new
|
53
53
|
else
|
54
54
|
before_perform
|
55
|
-
lock
|
55
|
+
lock ? with_lock(&block) : yield(self)
|
56
56
|
end
|
57
57
|
rescue Lockistics::LockTimeout
|
58
58
|
@lock_timeouts = 1
|
@@ -117,7 +117,7 @@ module Lockistics
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def before_perform
|
120
|
-
Lockistics.known_keys(key)
|
120
|
+
Lockistics.known_keys(key) unless options[:no_metrics]
|
121
121
|
@start_time = Time.now.to_f
|
122
122
|
@start_rss = OS.rss_bytes
|
123
123
|
redis.pipelined do
|
data/lib/lockistics/version.rb
CHANGED
data/spec/meter_spec.rb
CHANGED
@@ -99,9 +99,10 @@ describe "Lockistics.meter" do
|
|
99
99
|
|
100
100
|
it "should know known keys" do
|
101
101
|
Lockistics.redis.del("lockistics.known_keys")
|
102
|
-
Lockistics.
|
102
|
+
Lockistics.meter("mtest1") {}
|
103
103
|
Lockistics.meter("mtest2") {}
|
104
104
|
Lockistics.meterlock("mtest3", :wait => false, :raise => false) {}
|
105
|
+
Lockistics.lock("mtest4", :wait => false, :raise => false) {}
|
105
106
|
Lockistics.known_keys.include?("mtest1").should be_true
|
106
107
|
Lockistics.known_keys.include?("mtest2").should be_true
|
107
108
|
Lockistics.known_keys.include?("mtest3").should be_true
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,9 @@ RSpec.configure do |config|
|
|
8
8
|
config.run_all_when_everything_filtered = true
|
9
9
|
config.filter_run :focus
|
10
10
|
config.order = 'random'
|
11
|
+
config.before(:each) do
|
12
|
+
Redis::Connection::Memory.reset_all_databases
|
13
|
+
end
|
11
14
|
end
|
12
15
|
|
13
16
|
class Redis
|
@@ -54,3 +57,4 @@ class Redis
|
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
60
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lockistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kimmo Lehto
|