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 +4 -4
- data/.travis.yml +6 -1
- data/README.md +1 -0
- data/lib/cachext/client.rb +2 -2
- data/lib/cachext/configuration.rb +14 -0
- data/lib/cachext/features/debug_logging.rb +4 -6
- data/lib/cachext/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcf7bc76ec3652f1cd422829ce48eab33dcca9fa
|
4
|
+
data.tar.gz: c0b1da10550b40c1b8a3b177ad3af8db1e6e1a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baedf859f3f071c3f8d55d3dce7f23017bc220eb66a9c4c1d38f0eb4b07d1cd463aec1d158b83f0d277be26ccfdcaf167630122ab002b32ea0348080758d3103
|
7
|
+
data.tar.gz: 70b82bbbec5dcca57cf5a5b2d894b13c17f359fb5a195f3918836a0998a8b1f812c83650c3c428d0821adbf80329ebe101901f8749e8d9dc2ba5b811d49d28a2
|
data/.travis.yml
CHANGED
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
|
|
data/lib/cachext/client.rb
CHANGED
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
data/lib/cachext/version.rb
CHANGED
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.
|
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:
|
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.
|
218
|
+
rubygems_version: 2.5.1
|
219
219
|
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: Cache with lock and backup extensions
|