lock_and_cache 0.0.4 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21d17e2c8ff95fb3fd66d96f0650d50621193108
4
- data.tar.gz: ea18fa126b940341107b04b86c39775b968fd2bd
3
+ metadata.gz: 2fe1e1aa249ac319cc720916c9f3677caad588c7
4
+ data.tar.gz: 4cc645768c09dbdadecf4acc1fd725f74f0868a3
5
5
  SHA512:
6
- metadata.gz: 3273a8c796feffc24eb7628c6617888ce17c009c2db56fb442ef04671f30e9fb6688757e2d6ca6f69f5c38e72461921aa50996ca15f29b6177b03b7c262c0a96
7
- data.tar.gz: d15442362206917ac53a4a396bcf8249f7f0bf346dfdefcb59be473ab2e2184923df80155888b85619cd7e39f4e5764bcf8b7f91dd8407a6e5b409a399785d58
6
+ metadata.gz: f9560ee842aaaf400e9685066b7758ceb5c654ec86e218f8f79ad75e9d9e9f2ab1df602e4645a031323c969666449c7b8157c6cf0e08eef8252e7fa3a235cf77
7
+ data.tar.gz: 7b7f13f14b8a6fd2a03a4dbd860b1edd5fb9090fcbdc9e6b8c1f4f64c88ecd2a98fd02eaf2fb575f5e8ee5c59d9e0e3973fb2abf8cf13c8c902d0433a79b7473
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.0.5 / 2014-12-12
2
+
3
+ * Enhancements
4
+
5
+ * ENV['LOCK_AND_CACHE_DEBUG'] == 'true' debug output to $stderr
6
+
1
7
  0.0.4 / 2014-12-12
2
8
 
3
9
  * Bug fixes
@@ -12,14 +12,20 @@ module LockAndCache
12
12
  alias_method unlocked_method_id, method_id
13
13
 
14
14
  define_method method_id do |*args|
15
+ debug = (ENV['LOCK_AND_CACHE_DEBUG'] == 'true')
15
16
  lock_key = [self.class.name, method_id, HashDigest.digest3([as_cache_key]+args)].join('/')
17
+ debug_lock_key = [self.class.name, method_id, [as_cache_key]+args].join('/') if debug
18
+ Thread.exclusive { $stderr.puts "[lock_and_cache] A #{debug_lock_key}" } if debug
16
19
  if cache_method_cached?(method_id, args)
17
20
  return send(method_id, *args) # which will be the cached version
18
21
  end
22
+ Thread.exclusive { $stderr.puts "[lock_and_cache] B #{debug_lock_key}" } if debug
19
23
  ActiveRecord::Base.with_advisory_lock(lock_key) do
24
+ Thread.exclusive { $stderr.puts "[lock_and_cache] C #{debug_lock_key}" } if debug
20
25
  if cache_method_cached?(method_id, args)
21
26
  send method_id, *args # which will be the cached version
22
27
  else
28
+ Thread.exclusive { $stderr.puts "[lock_and_cache] D #{debug_lock_key}" } if debug
23
29
  send unlocked_method_id, *args
24
30
  end
25
31
  end
@@ -1,3 +1,3 @@
1
1
  module LockAndCache
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_and_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere