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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +3 -3
- data/lib/stockpile/cached_value_expirer.rb +28 -0
- data/lib/stockpile/constants.rb +1 -1
- data/lib/stockpile.rb +11 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 693694f88fe7bc244efc5a387a5ac8db0cfbf88077cd2f176cf06020284d5b46
|
4
|
+
data.tar.gz: 49634209b32de18fec7e4d69713c0dd77a2be3e4fd8eb6943ca0ba5481ca4024
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe404c18fbc4dce1683faa40ba09b7e7d40eba3a2298e8502b798baee743dc0ec38ca9a13a10f874c1c952c601fef9383f8c83e3eb68251ed8eed9e4cf8118c1
|
7
|
+
data.tar.gz: 5b6a36ca3474feebddc0f30dec0594f75df97bd1342be8bf4bbe27ce9f75724696d0b032eba87e743f14ab69a9a9ff5290bb626099239e84e3c6dc438c88a1e3
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stockpile_cache (1.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 (
|
23
|
-
redis (4.1.
|
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
|
data/lib/stockpile/constants.rb
CHANGED
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
|
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-
|
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
|