cacheflow 0.2.1 → 0.3.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 +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +0 -2
- data/lib/cacheflow/redis.rb +29 -1
- data/lib/cacheflow/sidekiq.rb +24 -0
- data/lib/cacheflow/version.rb +1 -1
- data/lib/cacheflow.rb +5 -26
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0860f01c1abf80c54762bfdf0c80c191fa2ea956144958ffe4352a6fe0ad523c'
|
4
|
+
data.tar.gz: 519476b589957dc270569af29f7e57334f9ac7dff2cfa8d54771f531901a0d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2639a41bda572120361f2f8f13e5924478aa1a410931b2256679bc97e37869fb7439c57ab48ab577f8a0f82a1fc2c705df7d198b66d8ec7e19ce8ed9b081facd
|
7
|
+
data.tar.gz: 368024e42b9d7a838847ba671f9ce91079bbd0ea0f879b70702dd00c2cf84df61f0ef30b32c67c54a86d397a008f508f5373e39a16360c87471f2cfb75d6fcd3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 0.3.1 (2023-02-15)
|
2
|
+
|
3
|
+
- Fixed error with `redis-client`
|
4
|
+
|
5
|
+
## 0.3.0 (2022-09-05)
|
6
|
+
|
7
|
+
- Added support for `redis` 5 and `redis-client` gems
|
8
|
+
- Dropped support for Ruby < 2.7 and Active Support < 6
|
9
|
+
|
1
10
|
## 0.2.1 (2022-01-12)
|
2
11
|
|
3
12
|
- Fixed deprecation warning with Dalli 3
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
Colorized logging for Memcached and Redis
|
4
4
|
|
5
|
-
![Screenshot](https://gist.githubusercontent.com/ankane/64d630db934c5222587794232a690864/raw/880b70fdbd2d11ccc8475f4616397184918852e8/console.png)
|
6
|
-
|
7
5
|
Works with the Rails cache, as well as [Dalli](https://github.com/petergoldstein/dalli) and [Redis](https://github.com/redis/redis-rb) clients directly
|
8
6
|
|
9
7
|
[![Build Status](https://github.com/ankane/cacheflow/workflows/build/badge.svg?branch=master)](https://github.com/ankane/cacheflow/actions)
|
data/lib/cacheflow/redis.rb
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
module Cacheflow
|
2
2
|
module Redis
|
3
|
+
# redis 5 / redis-client
|
4
|
+
module ClientNotifications
|
5
|
+
def call(command, redis_config)
|
6
|
+
payload = {
|
7
|
+
commands: [command]
|
8
|
+
}
|
9
|
+
ActiveSupport::Notifications.instrument("query.redis", payload) do
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def call_pipelined(commands, redis_config)
|
15
|
+
payload = {
|
16
|
+
commands: commands
|
17
|
+
}
|
18
|
+
ActiveSupport::Notifications.instrument("query.redis", payload) do
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# redis 4
|
3
25
|
module Notifications
|
4
26
|
def logging(commands)
|
5
27
|
payload = {
|
@@ -28,5 +50,11 @@ module Cacheflow
|
|
28
50
|
end
|
29
51
|
end
|
30
52
|
|
31
|
-
|
53
|
+
if defined?(RedisClient)
|
54
|
+
RedisClient.register(Cacheflow::Redis::ClientNotifications)
|
55
|
+
elsif defined?(Redis)
|
56
|
+
# redis < 5
|
57
|
+
Redis::Client.prepend(Cacheflow::Redis::Notifications)
|
58
|
+
end
|
59
|
+
|
32
60
|
Cacheflow::Redis::Instrumenter.attach_to(:redis)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Cacheflow
|
2
|
+
module Sidekiq
|
3
|
+
module ClassMethods
|
4
|
+
def redis(*_)
|
5
|
+
Cacheflow.silence do
|
6
|
+
super
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Client
|
12
|
+
module InstanceMethods
|
13
|
+
def push(*_)
|
14
|
+
Cacheflow.silence do
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
::Sidekiq.singleton_class.prepend(Cacheflow::Sidekiq::ClassMethods)
|
24
|
+
::Sidekiq::Client.prepend(Cacheflow::Sidekiq::Client::InstanceMethods)
|
data/lib/cacheflow/version.rb
CHANGED
data/lib/cacheflow.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
require "active_support"
|
3
3
|
|
4
4
|
# modules
|
5
|
-
|
5
|
+
require_relative "cacheflow/version"
|
6
6
|
|
7
7
|
module Cacheflow
|
8
8
|
def self.activate
|
9
|
-
|
10
|
-
|
9
|
+
require_relative "cacheflow/memcached" if defined?(Dalli)
|
10
|
+
require_relative "cacheflow/redis" if defined?(Redis) || defined?(RedisClient)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.silenced?
|
@@ -25,33 +25,12 @@ module Cacheflow
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.silence_sidekiq!
|
28
|
-
|
29
|
-
::Sidekiq::Client.prepend(Cacheflow::Sidekiq::Client::InstanceMethods)
|
30
|
-
end
|
31
|
-
|
32
|
-
module Sidekiq
|
33
|
-
module ClassMethods
|
34
|
-
def redis(*_)
|
35
|
-
Cacheflow.silence do
|
36
|
-
super
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
module Client
|
42
|
-
module InstanceMethods
|
43
|
-
def push(*_)
|
44
|
-
Cacheflow.silence do
|
45
|
-
super
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
28
|
+
require_relative "cacheflow/sidekiq"
|
50
29
|
end
|
51
30
|
end
|
52
31
|
|
53
32
|
if defined?(Rails)
|
54
|
-
|
33
|
+
require_relative "cacheflow/railtie"
|
55
34
|
else
|
56
35
|
Cacheflow.activate
|
57
36
|
end
|
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.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6'
|
27
27
|
description:
|
28
28
|
email: andrew@ankane.org
|
29
29
|
executables: []
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/cacheflow/memcached.rb
|
38
38
|
- lib/cacheflow/railtie.rb
|
39
39
|
- lib/cacheflow/redis.rb
|
40
|
+
- lib/cacheflow/sidekiq.rb
|
40
41
|
- lib/cacheflow/version.rb
|
41
42
|
homepage: https://github.com/ankane/cacheflow
|
42
43
|
licenses:
|
@@ -50,14 +51,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
51
|
requirements:
|
51
52
|
- - ">="
|
52
53
|
- !ruby/object:Gem::Version
|
53
|
-
version: '2.
|
54
|
+
version: '2.7'
|
54
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
56
|
requirements:
|
56
57
|
- - ">="
|
57
58
|
- !ruby/object:Gem::Version
|
58
59
|
version: '0'
|
59
60
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
61
|
+
rubygems_version: 3.4.6
|
61
62
|
signing_key:
|
62
63
|
specification_version: 4
|
63
64
|
summary: Colorized logging for Memcached and Redis
|