cachext 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57e65ad4f06f5acff5ddc4d5b3554fb9bd49ec5
4
- data.tar.gz: 964fed39f446dda576f5505a8489254718507a50
3
+ metadata.gz: dcf7bc76ec3652f1cd422829ce48eab33dcca9fa
4
+ data.tar.gz: c0b1da10550b40c1b8a3b177ad3af8db1e6e1a6d
5
5
  SHA512:
6
- metadata.gz: 9a3e5777bcb4d6c4f0183e10c3738416f807ad8edb7102ba4fb4a08da3a340bf2f3e229bb113aaea4d310b751f68d01e6a6bdee2543e7cee7089322cfc6344fb
7
- data.tar.gz: 8f4d957745f93daf3e20a6abf7dd5f3b1283a7d3a906410b97e64011a1aec0fcda2cf3153f202d3316d383296f51c50e78deee5686744e458668fc009af802f3
6
+ metadata.gz: baedf859f3f071c3f8d55d3dce7f23017bc220eb66a9c4c1d38f0eb4b07d1cd463aec1d158b83f0d277be26ccfdcaf167630122ab002b32ea0348080758d3103
7
+ data.tar.gz: 70b82bbbec5dcca57cf5a5b2d894b13c17f359fb5a195f3918836a0998a8b1f812c83650c3c428d0821adbf80329ebe101901f8749e8d9dc2ba5b811d49d28a2
data/.travis.yml CHANGED
@@ -1,7 +1,12 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.3
3
+ - 2.1.8
4
+ - 2.2.4
5
+ - 2.3.0
4
6
  before_install: gem install bundler -v 1.10.6
5
7
  services:
6
8
  - memcache
7
9
  - redis
10
+ addons:
11
+ code_climate:
12
+ repo_token: cb086fed31c856366899aee6853db25d307c6a85c7c67390f7dcd17eb71f2d20
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/dplummer/cachext.svg)](https://travis-ci.org/dplummer/cachext)
4
4
  [![Gem Version](https://badge.fury.io/rb/cachext.svg)](https://badge.fury.io/rb/cachext)
5
+ [![Code Climate](https://codeclimate.com/github/dplummer/cachext/badges/gpa.svg)](https://codeclimate.com/github/dplummer/cachext)
5
6
 
6
7
  Extensions to normal Rails caching:
7
8
 
@@ -11,7 +11,7 @@ module Cachext
11
11
  @config = config
12
12
  end
13
13
 
14
- def fetch key, options_hash, &block
14
+ def fetch key, options_hash = {}, &block
15
15
  options = Options.new @config, options_hash
16
16
 
17
17
  retval = read key, options
@@ -41,7 +41,7 @@ module Cachext
41
41
 
42
42
  def handle_error key, options, error
43
43
  @config.error_logger.call error if @config.log_errors?
44
- raise if @config.raise_errors && reraise_errors
44
+ raise if @config.raise_errors && options.reraise_errors
45
45
  end
46
46
 
47
47
  def read key, options
@@ -1,5 +1,6 @@
1
1
  require "redlock"
2
2
  require "redis-namespace"
3
+ require "thread"
3
4
 
4
5
  module Cachext
5
6
  class Configuration
@@ -46,6 +47,7 @@ module Cachext
46
47
  self.max_lock_wait = 5
47
48
  self.debug = ENV['CACHEXT_DEBUG'] == "true"
48
49
  self.heartbeat_expires = 2
50
+ @debug_mutex = Mutex.new
49
51
  end
50
52
 
51
53
  def lock_manager
@@ -59,5 +61,17 @@ module Cachext
59
61
  def log_errors?
60
62
  error_logger.present?
61
63
  end
64
+
65
+ def debug
66
+ if block_given?
67
+ if @debug
68
+ @mutex.synchronize do
69
+ yield
70
+ end
71
+ end
72
+ else
73
+ @debug
74
+ end
75
+ end
62
76
  end
63
77
  end
@@ -37,12 +37,10 @@ module Cachext
37
37
  end
38
38
 
39
39
  def debug_log
40
- if @config.debug
41
- Thread.exclusive do
42
- log = yield
43
- msg = log.is_a?(String) ? log : log.inspect
44
- $stderr.puts "[#{Time.now.to_s(:db)}] [#{Process.pid} #{Thread.current.object_id.to_s(16)}] #{msg}"
45
- end
40
+ @config.debug do
41
+ log = yield
42
+ msg = log.is_a?(String) ? log : log.inspect
43
+ $stderr.puts "[#{Time.now.to_s(:db)}] [#{Process.pid} #{Thread.current.object_id.to_s(16)}] #{msg}"
46
44
  end
47
45
  end
48
46
  end
@@ -1,3 +1,3 @@
1
1
  module Cachext
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cachext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Plummer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
215
  version: '0'
216
216
  requirements: []
217
217
  rubyforge_project:
218
- rubygems_version: 2.4.5.1
218
+ rubygems_version: 2.5.1
219
219
  signing_key:
220
220
  specification_version: 4
221
221
  summary: Cache with lock and backup extensions