stockpile_cache 1.0.1 → 1.1.0

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
  SHA256:
3
- metadata.gz: be776cc6d3422c9cf860af58b463cdbc72dff81c615511484e29e3d646b00ce4
4
- data.tar.gz: ae98206437c01ed7b15a92a502450e4c31370822e5a003b74d2d177a0aafb2ee
3
+ metadata.gz: 693694f88fe7bc244efc5a387a5ac8db0cfbf88077cd2f176cf06020284d5b46
4
+ data.tar.gz: 49634209b32de18fec7e4d69713c0dd77a2be3e4fd8eb6943ca0ba5481ca4024
5
5
  SHA512:
6
- metadata.gz: 6aaf1c67c7593e9788bc595d9a42815e840714c70d63b70f7891e5aeb52a8d018e0b784fd0c2801b33fae3599e93e3874edf6478b1100b88aae31ef00d302547
7
- data.tar.gz: a3ce357ee412fb2d01d695a75257b8eb7aac84b1b81a410b0debc80e555ad19ac80504e7c935de741f5a1bba9d97c68fb6faf2ed4afbd8a21f6142bca36dbdf4
6
+ metadata.gz: fe404c18fbc4dce1683faa40ba09b7e7d40eba3a2298e8502b798baee743dc0ec38ca9a13a10f874c1c952c601fef9383f8c83e3eb68251ed8eed9e4cf8118c1
7
+ data.tar.gz: 5b6a36ca3474feebddc0f30dec0594f75df97bd1342be8bf4bbe27ce9f75724696d0b032eba87e743f14ab69a9a9ff5290bb626099239e84e3c6dc438c88a1e3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+ - Allowing expiration of cached value
5
+
3
6
  ## 1.0.1
4
7
  - Adding CHANGELOG.md
5
8
  - Removing homepage from gemspec as we don't have proper one yet
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stockpile_cache (1.0.0)
4
+ stockpile_cache (1.0.1)
5
5
  connection_pool
6
6
  oj
7
7
  rake
@@ -19,8 +19,8 @@ GEM
19
19
  parser (2.6.4.1)
20
20
  ast (~> 2.4.0)
21
21
  rainbow (3.0.0)
22
- rake (12.3.3)
23
- redis (4.1.2)
22
+ rake (13.0.0)
23
+ redis (4.1.3)
24
24
  rspec (3.8.0)
25
25
  rspec-core (~> 3.8.0)
26
26
  rspec-expectations (~> 3.8.0)
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2019 ConvertKit, LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module Stockpile
18
+ # == Stockpile::CachedValueExpirer
19
+ #
20
+ # Service class to wrap expiration of of cached value
21
+ module CachedValueExpirer
22
+ module_function
23
+
24
+ def expire_cached(key:)
25
+ Stockpile.redis { |r| r.expire(key, 0) }
26
+ end
27
+ end
28
+ end
@@ -23,5 +23,5 @@ module Stockpile
23
23
  DEFAULT_TTL = 60 * 5
24
24
  LOCK_PREFIX = 'stockpile_lock::'
25
25
  SLUMBER_COOLDOWN = 0.05
26
- VERSION = '1.0.1'
26
+ VERSION = '1.1.0'
27
27
  end
data/lib/stockpile.rb CHANGED
@@ -29,6 +29,7 @@ require 'stockpile/failed_lock_execution'
29
29
 
30
30
  require 'stockpile/cache'
31
31
  require 'stockpile/cached_value_reader'
32
+ require 'stockpile/cached_value_expirer'
32
33
 
33
34
  require 'stockpile/executor'
34
35
 
@@ -72,6 +73,16 @@ module Stockpile
72
73
  nil
73
74
  end
74
75
 
76
+ # Immediatelly expires a cached value for a given key.
77
+ #
78
+ # @params key [String] Key to expire
79
+ #
80
+ # @return [true, false] Returns true if value existed in cache and was
81
+ # succesfully expired. Returns false if value did not exist in cache.
82
+ def expire_cached(key:)
83
+ Stockpile::CachedValueExpirer.expire_cached(key: key)
84
+ end
85
+
75
86
  # Attempts to fetch a value from cache (for a given key). In case of miss
76
87
  # will execute given block of code and cache it's result at the provided
77
88
  # key for a specified TTL.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stockpile_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ConvertKit, LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-12 00:00:00.000000000 Z
11
+ date: 2019-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -89,6 +89,7 @@ files:
89
89
  - bin/setup
90
90
  - lib/stockpile.rb
91
91
  - lib/stockpile/cache.rb
92
+ - lib/stockpile/cached_value_expirer.rb
92
93
  - lib/stockpile/cached_value_reader.rb
93
94
  - lib/stockpile/configuration.rb
94
95
  - lib/stockpile/constants.rb