lockistics 0.1.1 → 0.1.2

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.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
@@ -18,7 +18,6 @@ module Lockistics
18
18
 
19
19
  def acquire_lock
20
20
  return true if options[:pass_through]
21
- Lockistics.known_keys(key)
22
21
  if got_lock?
23
22
  true
24
23
  elsif options[:wait]
@@ -52,7 +52,7 @@ module Lockistics
52
52
  yield DummyMeter.new
53
53
  else
54
54
  before_perform
55
- lock.nil? ? yield(self) : with_lock(&block)
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
@@ -1,3 +1,3 @@
1
1
  module Lockistics
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.lock("mtest1", :wait => false, :raise => false) {}
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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kimmo Lehto