fluent-plugin-storage-redis 0.0.3 → 0.0.4

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: 51884bbb0e07a0252f7a22745b37b5321c59405e
4
- data.tar.gz: 1491129c6380b40e24f8e15f53baba61bef3eb52
3
+ metadata.gz: 45c036a2d960d3cc7bedda93dce3a318da12504c
4
+ data.tar.gz: 900f4668a055d960564ca5737d582cb5c0b47778
5
5
  SHA512:
6
- metadata.gz: ee6cb8f56f90ff1786652b435465a43c1f401469c9e903549c03e6ec3baaaf550688d48476878f75fb7865efbc063eed914554d81826f620f8a1f6d236f7f0c3
7
- data.tar.gz: a349388cc4249e36ec6876fe8d7327f18adfcc61307929560dd1202542466c406901acab495ca907c1408bc25c9895c61620baf9a0fb1c84e562f6d86cacd5eb
6
+ metadata.gz: 2dfab51e61bcce2948dee8b39bd42ada4cda5fcd9d5c2f2073903e6809c12de3b0850ccf2c8d5d3ad822d735f6f56cbdc17cce65520816f2dd328ab739f0bd46
7
+ data.tar.gz: 829a1e1202262ed7994edb0528336f7f67039cc88a4278a390f542561bb2df6272acdb229192597dde6b173d5bb64bebba6ab92200f867fda22e4aeaaaf916d0
data/README.md CHANGED
@@ -34,6 +34,7 @@ Then fluent automatically loads the plugin installed.
34
34
  db_number 0 # 0 is default
35
35
  # If requirepass is set, please specify this.
36
36
  # password hogefuga
37
+ # ttl 300 # If 0 or negative value is set, ttl is not set in each key.
37
38
  </storage>
38
39
  ```
39
40
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-storage-redis"
7
- spec.version = "0.0.3"
7
+ spec.version = "0.0.4"
8
8
  spec.authors = ["Hiroshi Hatake"]
9
9
  spec.email = ["cosmo0920.oucc@gmail.com"]
10
10
 
@@ -6,11 +6,14 @@ module Fluent
6
6
  class RedisStorage < Storage
7
7
  Fluent::Plugin.register_storage('redis', self)
8
8
 
9
+ DEFAULT_TTL_VALUE = -1
10
+
9
11
  config_param :path, :string, default: nil
10
12
  config_param :host, :string, default: 'localhost'
11
13
  config_param :port, :integer, default: 6379
12
14
  config_param :db_number, :integer, default: 0
13
15
  config_param :password, :string, default: nil, secret: true
16
+ config_param :ttl, :integer, default: DEFAULT_TTL_VALUE
14
17
  # Set persistent true by default
15
18
  config_set_default :persistent, true
16
19
 
@@ -66,6 +69,7 @@ module Fluent
66
69
  def load
67
70
  begin
68
71
  json_string = @redis.get(@path)
72
+ json_string ||= "{}" # for ttl support.
69
73
  json = Yajl::Parser.parse(json_string)
70
74
  unless json.is_a?(Hash)
71
75
  log.error "broken content for plugin storage (Hash required: ignored)", type: json.class
@@ -82,7 +86,10 @@ module Fluent
82
86
  begin
83
87
  json_string = Yajl::Encoder.encode(@store)
84
88
  @redis.pipelined {
85
- @redis.set(@path, json_string)
89
+ @redis.multi do
90
+ @redis.set(@path, json_string)
91
+ @redis.expire(@path, @ttl) if @ttl > 0
92
+ end
86
93
  }
87
94
  rescue => e
88
95
  log.error "failed to save data for plugin storage to redis", path: @path, error: e
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-storage-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler