cacheflow 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +17 -1
- data/lib/cacheflow.rb +39 -0
- data/lib/cacheflow/memcached.rb +1 -1
- data/lib/cacheflow/redis.rb +1 -1
- data/lib/cacheflow/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac0a2640873e62e3bbb8770586da459cc7de3657
|
4
|
+
data.tar.gz: 5359925b29dd20b4006c44c214ab5313b2114313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6148305fbd5825dd61031e813b080c105076b45ab341b12a7fa908f440d9e4125d457ea2ee4039cd02614dcb99fa8fee967e920c5a34c0192389afb9fe49bfd6
|
7
|
+
data.tar.gz: c3382fb7dc4f4c125ecc9c1d3e234060103d316540fb968a32e35b9a5d76e36ab84ba181fc509f216feb6ffad92944c4677aece4a9769f4a3fbbf71b9555ce99
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,11 +11,27 @@ Works with the Rails cache, as well as [Dalli](https://github.com/petergoldstein
|
|
11
11
|
Add this line to your application’s Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem 'cacheflow'
|
14
|
+
gem 'cacheflow', group: :development
|
15
15
|
```
|
16
16
|
|
17
17
|
When your log level is set to `DEBUG` (Rails default in development), all commands to Memcached and Redis are logged.
|
18
18
|
|
19
|
+
## Features
|
20
|
+
|
21
|
+
To silence logging, use:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Cacheflow.silence do
|
25
|
+
# code
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
To silence logging for only [Sidekiq](https://github.com/mperham/sidekiq) commands, create an initializer with:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Cacheflow.silence_sidekiq!
|
33
|
+
```
|
34
|
+
|
19
35
|
## History
|
20
36
|
|
21
37
|
View the [changelog](https://github.com/ankane/cacheflow/blob/master/CHANGELOG.md)
|
data/lib/cacheflow.rb
CHANGED
@@ -6,6 +6,45 @@ module Cacheflow
|
|
6
6
|
require "cacheflow/memcached" if defined?(Dalli)
|
7
7
|
require "cacheflow/redis" if defined?(Redis)
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.silenced?
|
11
|
+
Thread.current[:cacheflow_silenced]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.silence
|
15
|
+
previous_value = silenced?
|
16
|
+
begin
|
17
|
+
Thread.current[:cacheflow_silenced] = true
|
18
|
+
yield
|
19
|
+
ensure
|
20
|
+
Thread.current[:cacheflow_silenced] = previous_value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.silence_sidekiq!
|
25
|
+
::Sidekiq.singleton_class.prepend(Cacheflow::Sidekiq::ClassMethods)
|
26
|
+
::Sidekiq::Client.prepend(Cacheflow::Sidekiq::Client::InstanceMethods)
|
27
|
+
end
|
28
|
+
|
29
|
+
module Sidekiq
|
30
|
+
module ClassMethods
|
31
|
+
def redis(*_)
|
32
|
+
Cacheflow.silence do
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Client
|
39
|
+
module InstanceMethods
|
40
|
+
def push(*_)
|
41
|
+
Cacheflow.silence do
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
9
48
|
end
|
10
49
|
|
11
50
|
if defined?(Rails)
|
data/lib/cacheflow/memcached.rb
CHANGED
@@ -14,7 +14,7 @@ module Cacheflow
|
|
14
14
|
|
15
15
|
class Instrumenter < ActiveSupport::LogSubscriber
|
16
16
|
def query(event)
|
17
|
-
return
|
17
|
+
return if !logger.debug? || Cacheflow.silenced?
|
18
18
|
|
19
19
|
name = "%s (%.2fms)" % ["Memcached", event.duration]
|
20
20
|
debug " #{color(name, BLUE, true)} #{event.payload[:op].to_s.upcase} #{event.payload[:args].join(" ")}"
|
data/lib/cacheflow/redis.rb
CHANGED
data/lib/cacheflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cacheflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|