zache 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codecov.yml +20 -0
- data/.github/workflows/pdd.yml +15 -0
- data/.github/workflows/rake.yml +24 -0
- data/.github/workflows/xcop.yml +17 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/.rultor.yml +9 -14
- data/Gemfile +10 -2
- data/LICENSE.txt +21 -0
- data/README.md +15 -30
- data/Rakefile +10 -2
- data/lib/zache.rb +11 -10
- data/logo.svg +19 -0
- data/renovate.json +6 -0
- data/test/test__helper.rb +28 -0
- data/test/test_zache.rb +9 -2
- data/zache.gemspec +4 -15
- metadata +16 -108
- data/.travis.yml +0 -12
- data/appveyor.yml +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52760a54efe8ed00af83cbe98b8b3b36c7e1ab04f762a99ad0380d21707dd98f
|
4
|
+
data.tar.gz: aa331388655a2bba662ddb62bea69f697ab0c60a8be39a7df97b837d8ac00398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b688035cc5e1fd829b78284f51301e248ceb6fb7b851d1f9f519b04c6115394f170a77655eabf6d3b0c4cc64aa5a56bc5470be6aa7bfb4f2bdeced54e15ff26
|
7
|
+
data.tar.gz: 853615cc3abe9002edc5cb4590981076733a6707f280b333b462ad37c2cf17dd691edd5f8ad6f4fbaf65fb5296b2e24dee2228d99250129190d009156c1056d8
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: codecov
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
jobs:
|
8
|
+
codecov:
|
9
|
+
runs-on: ubuntu-20.04
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v3
|
12
|
+
- uses: actions/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 3.0
|
15
|
+
- run: bundle update
|
16
|
+
- run: bundle exec rake
|
17
|
+
- uses: codecov/codecov-action@v3
|
18
|
+
with:
|
19
|
+
file: coverage/.resultset.json
|
20
|
+
fail_ci_if_error: true
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
name: rake
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
name: test
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
os: [ubuntu-20.04]
|
16
|
+
ruby: [3.0, 2.7]
|
17
|
+
runs-on: ${{ matrix.os }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v3
|
20
|
+
- uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- run: bundle update
|
24
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisplayCopNames: true
|
3
3
|
TargetRubyVersion: 2.5
|
4
|
+
NewCops: enable
|
5
|
+
SuggestExtensions: false
|
4
6
|
|
5
7
|
Metrics/ClassLength:
|
6
8
|
Exclude:
|
@@ -17,3 +19,7 @@ Metrics/CyclomaticComplexity:
|
|
17
19
|
Max: 12
|
18
20
|
Metrics/PerceivedComplexity:
|
19
21
|
Max: 12
|
22
|
+
Layout/EndOfLine:
|
23
|
+
EnforcedStyle: lf
|
24
|
+
Metrics/BlockLength:
|
25
|
+
Max: 28
|
data/.rultor.yml
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
+
docker:
|
2
|
+
image: yegor256/rultor-image:1.19.0
|
1
3
|
assets:
|
2
|
-
rubygems.yml:
|
3
|
-
install:
|
4
|
-
|
5
|
-
|
4
|
+
rubygems.yml: yegor256/home#assets/rubygems.yml
|
5
|
+
install: |
|
6
|
+
pdd -f /dev/null
|
7
|
+
sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
6
8
|
release:
|
7
9
|
script: |-
|
8
|
-
bundle
|
9
|
-
|
10
|
+
bundle exec rake
|
11
|
+
pdd -f /dev/null
|
10
12
|
rm -rf *.gem
|
11
13
|
sed -i "s/0\.0\.0/${tag}/g" zache.gemspec
|
12
14
|
git add zache.gemspec
|
@@ -14,13 +16,6 @@ release:
|
|
14
16
|
gem build zache.gemspec
|
15
17
|
chmod 0600 ../rubygems.yml
|
16
18
|
gem push *.gem --config-file ../rubygems.yml
|
17
|
-
commanders:
|
18
|
-
- yegor256
|
19
|
-
architect:
|
20
|
-
- yegor256
|
21
19
|
merge:
|
22
|
-
commanders: []
|
23
20
|
script: |-
|
24
|
-
bundle
|
25
|
-
rake
|
26
|
-
deploy: {}
|
21
|
+
bundle exec rake clean test rubocop copyright
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2018-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -21,5 +21,13 @@
|
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
23
|
source 'https://rubygems.org'
|
24
|
-
ruby '2.6.0'
|
25
24
|
gemspec
|
25
|
+
|
26
|
+
gem 'concurrent-ruby', '1.2.2', require: false
|
27
|
+
gem 'minitest', '5.18.0', require: false
|
28
|
+
gem 'rake', '13.0.6', require: false
|
29
|
+
gem 'rdoc', '6.5.0', require: false
|
30
|
+
gem 'rubocop', '1.51.0', require: false
|
31
|
+
gem 'rubocop-rspec', '2.22.0', require: false
|
32
|
+
gem 'simplecov', '0.22.0', require: false
|
33
|
+
gem 'threads', '0.3.0', require: false
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Yegor Bugayenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included
|
13
|
+
in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
|
1
|
+
<img src="/logo.svg" width="64px" height="64px"/>
|
2
|
+
|
3
|
+
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
|
2
4
|
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/zache)](http://www.rultor.com/p/yegor256/zache)
|
3
|
-
[![We recommend RubyMine](
|
5
|
+
[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
|
4
6
|
|
5
|
-
[![
|
6
|
-
[![Build status](https://ci.appveyor.com/api/projects/status/7eday736u9phnjiy?svg=true)](https://ci.appveyor.com/project/yegor256/zache)
|
7
|
+
[![rake](https://github.com/yegor256/zache/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/zache/actions/workflows/rake.yml)
|
7
8
|
[![Gem Version](https://badge.fury.io/rb/zache.svg)](http://badge.fury.io/rb/zache)
|
8
9
|
[![Maintainability](https://api.codeclimate.com/v1/badges/c136afe340fa94f14696/maintainability)](https://codeclimate.com/github/yegor256/zache/maintainability)
|
9
10
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/zache/master/frames)
|
11
|
+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/zache/blob/master/LICENSE.txt)
|
12
|
+
[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/zache.svg)](https://codecov.io/github/yegor256/zache?branch=master)
|
13
|
+
[![Hits-of-Code](https://hitsofcode.com/github/yegor256/zache)](https://hitsofcode.com/view/github/yegor256/zache)
|
10
14
|
|
11
15
|
It's a simple Ruby gem for in-memory cache.
|
16
|
+
Read [this blog post](https://www.yegor256.com/2019/02/05/zache.html)
|
17
|
+
to understand what Zache is for.
|
12
18
|
|
13
19
|
First, install it:
|
14
20
|
|
@@ -40,9 +46,12 @@ while another one calls `get` again. That second thread won't wait, but will
|
|
40
46
|
receive what's left in the cache. This is a very convenient mode for situations
|
41
47
|
when you don't really care about data accuracy, but performance is an issue.
|
42
48
|
|
49
|
+
The entire API is documented [here](https://www.rubydoc.info/github/yegor256/zache/master/Zache)
|
50
|
+
(there are many other convenient methods).
|
51
|
+
|
43
52
|
That's it.
|
44
53
|
|
45
|
-
|
54
|
+
## How to contribute
|
46
55
|
|
47
56
|
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
48
57
|
Make sure you build is green before you contribute
|
@@ -51,31 +60,7 @@ your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2
|
|
51
60
|
|
52
61
|
```
|
53
62
|
$ bundle update
|
54
|
-
$ rake
|
63
|
+
$ bundle exec rake
|
55
64
|
```
|
56
65
|
|
57
66
|
If it's clean and you don't see any error messages, submit your pull request.
|
58
|
-
|
59
|
-
# License
|
60
|
-
|
61
|
-
(The MIT License)
|
62
|
-
|
63
|
-
Copyright (c) 2018 Yegor Bugayenko
|
64
|
-
|
65
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
66
|
-
of this software and associated documentation files (the 'Software'), to deal
|
67
|
-
in the Software without restriction, including without limitation the rights
|
68
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
69
|
-
copies of the Software, and to permit persons to whom the Software is
|
70
|
-
furnished to do so, subject to the following conditions:
|
71
|
-
|
72
|
-
The above copyright notice and this permission notice shall be included in all
|
73
|
-
copies or substantial portions of the Software.
|
74
|
-
|
75
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
76
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
77
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
78
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
79
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
80
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
81
|
-
SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2018-2023 Yegor Bugayenko
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -34,7 +34,7 @@ def version
|
|
34
34
|
Gem::Specification.load(Dir['*.gemspec'].first).version
|
35
35
|
end
|
36
36
|
|
37
|
-
task default: %i[clean test rubocop]
|
37
|
+
task default: %i[clean test rubocop copyright]
|
38
38
|
|
39
39
|
require 'rake/testtask'
|
40
40
|
desc 'Run all unit tests'
|
@@ -57,3 +57,11 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
57
57
|
task.fail_on_error = true
|
58
58
|
task.requires << 'rubocop-rspec'
|
59
59
|
end
|
60
|
+
|
61
|
+
task :copyright do
|
62
|
+
sh "grep -q -r '2018-#{Date.today.strftime('%Y')}' \
|
63
|
+
--include '*.rb' \
|
64
|
+
--include '*.txt' \
|
65
|
+
--include 'Rakefile' \
|
66
|
+
."
|
67
|
+
end
|
data/lib/zache.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# (The MIT License)
|
4
4
|
#
|
5
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
5
|
+
# Copyright (c) 2018-2023 Yegor Bugayenko
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -34,7 +34,7 @@
|
|
34
34
|
# {README}[https://github.com/yegor256/zache/blob/master/README.md] file.
|
35
35
|
#
|
36
36
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
|
-
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
37
|
+
# Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
|
38
38
|
# License:: MIT
|
39
39
|
class Zache
|
40
40
|
# Fake implementation that doesn't cache anything, but behaves like it
|
@@ -67,6 +67,7 @@ class Zache
|
|
67
67
|
end
|
68
68
|
|
69
69
|
# Makes a new object of the cache.
|
70
|
+
#
|
70
71
|
# "sync" is whether the hash is thread-safe (`true`)
|
71
72
|
# or not (`false`); it is recommended to leave this parameter untouched,
|
72
73
|
# unless you really know what you are doing.
|
@@ -85,7 +86,9 @@ class Zache
|
|
85
86
|
@hash.size
|
86
87
|
end
|
87
88
|
|
88
|
-
# Gets the value from the cache by the provided key.
|
89
|
+
# Gets the value from the cache by the provided key.
|
90
|
+
#
|
91
|
+
# If the value is not
|
89
92
|
# found in the cache, it will be calculated via the provided block. If
|
90
93
|
# the block is not given, an exception will be raised (unless <tt>dirty</tt>
|
91
94
|
# is set to <tt>true</tt>). The lifetime
|
@@ -94,12 +97,10 @@ class Zache
|
|
94
97
|
#
|
95
98
|
# If the <tt>dirty</tt> argument is set to <tt>true</tt>, a previously
|
96
99
|
# calculated result will be returned if it exists and is already expired.
|
97
|
-
def get(key, lifetime: 2**32, dirty: false)
|
100
|
+
def get(key, lifetime: 2**32, dirty: false, &block)
|
98
101
|
if block_given?
|
99
|
-
if (dirty || @dirty) && locked? && expired?(key) && @hash.key?(key)
|
100
|
-
|
101
|
-
end
|
102
|
-
synchronized { calc(key, lifetime) { yield } }
|
102
|
+
return @hash[key][:value] if (dirty || @dirty) && locked? && expired?(key) && @hash.key?(key)
|
103
|
+
synchronized { calc(key, lifetime, &block) }
|
103
104
|
else
|
104
105
|
rec = @hash[key]
|
105
106
|
if expired?(key)
|
@@ -155,7 +156,7 @@ class Zache
|
|
155
156
|
end
|
156
157
|
|
157
158
|
# Removes the value from the hash, by the provied key. If the key is absent
|
158
|
-
# and the block is
|
159
|
+
# and the block is provided, the block will be called.
|
159
160
|
def remove(key)
|
160
161
|
synchronized { @hash.delete(key) { yield if block_given? } }
|
161
162
|
end
|
@@ -168,7 +169,7 @@ class Zache
|
|
168
169
|
# Remove all keys that match the block.
|
169
170
|
def remove_by
|
170
171
|
synchronized do
|
171
|
-
@hash.
|
172
|
+
@hash.each_key do |k|
|
172
173
|
@hash.delete(k) if yield(k)
|
173
174
|
end
|
174
175
|
end
|
data/logo.svg
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<svg width="314px" height="314px" viewBox="0 0 314 314" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
3
|
+
<!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
|
4
|
+
<title>Group 2</title>
|
5
|
+
<desc>Created with Sketch.</desc>
|
6
|
+
<defs></defs>
|
7
|
+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
8
|
+
<g id="Group-2">
|
9
|
+
<g id="Group">
|
10
|
+
<circle id="Oval" fill="#053C5E" cx="157" cy="157" r="157"></circle>
|
11
|
+
<rect id="Rectangle" fill="#2B2B2B" x="0" y="234" width="212" height="68"></rect>
|
12
|
+
<text id="zache" font-family="CourierNewPS-BoldMT, Courier New" font-size="50" font-weight="bold" fill="#FFFFFF">
|
13
|
+
<tspan x="28" y="282">zache</tspan>
|
14
|
+
</text>
|
15
|
+
<path d="M135.676765,111.215287 C135.211714,113.540467 132.770932,120.688823 130.252813,127.100603 C127.734621,133.512383 125.2898,140.431445 124.819828,142.476214 C123.6868,147.405663 121.517836,147.185477 119.69487,141.95608 C116.899865,133.938362 105.171362,111.043501 103.859129,111.043501 C100.420089,111.043501 101.508757,114.986149 109.1771,130.30227 C113.739327,139.414532 118.032086,147.448041 118.716515,148.15443 C120.694817,150.196115 120.172626,154.319657 117.358599,158.877992 C113.567467,165.019055 107.570942,183.721189 108.054206,187.896804 C108.804956,194.383204 112.436054,192.210274 113.355359,184.724515 C114.48376,175.535577 120.945556,159.641154 124.897459,156.333653 C127.109021,154.482778 128.268636,151.905536 128.573284,148.163978 C128.818001,145.157747 131.906711,135.560972 135.437115,126.837819 C138.96752,118.114666 141.511492,110.079835 141.090434,108.982574 C139.755727,105.504315 136.554941,106.824333 135.676765,111.215287 M174.714659,126.841564 C169.37392,129.699438 169.197653,130.049915 167.452978,141.283475 C165.577352,153.360398 165.225112,168.513913 166.548289,180.203784 L167.566817,189.202501 L161.346213,191.9541 C154.601949,194.937416 150.91195,200.302465 153.156708,203.861146 C155.104824,206.949562 157.09025,206.70198 157.571826,203.310532 C158.083734,199.706169 166.097413,193.204052 170.29418,192.987978 C172.116999,192.894116 173.522874,191.717021 173.97823,189.903529 C174.383277,188.290613 177.740353,184.944554 181.438431,182.467858 C188.546172,177.707551 194.317883,170.450278 194.317883,166.273341 C194.317883,162.684548 189.493165,158.361603 185.487795,158.361603 C180.701636,158.361603 180.027195,155.239403 183.731222,150.229385 C188.308065,144.038966 188.284856,130.867646 183.690534,127.147387 C179.896537,124.075276 179.885006,124.074836 174.714659,126.841564 M182.67318,134.240439 C184.752542,140.153164 174.808961,161.185104 171.588639,157.68562 C169.868715,155.81653 172.863122,135.012708 175.266374,132.134564 C177.872553,129.013319 181.163896,129.949075 182.67318,134.240439 M184.854262,162.269586 C190.589839,163.855621 189.673839,167.881335 181.645765,176.371155 C177.281618,180.986262 173.904933,183.573859 173.371946,182.711474 C172.876636,181.91012 172.127869,176.711937 171.707987,171.159972 L170.944531,161.065463 L176.209475,161.200234 C179.105172,161.274339 182.995308,161.755548 184.854262,162.269586 M132.642184,172.492256 C131.593837,175.224098 133.152917,177.288844 136.264027,177.288844 C139.014965,177.288844 139.431396,176.221769 138.067531,172.667568 C137.039234,169.987871 133.645289,169.878218 132.642184,172.492256 M203.781503,185.840798 C203.781503,187.657595 209.264724,193.512152 210.966361,193.512152 C212.534035,193.512152 211.991059,187.391138 210.270768,185.670847 C208.092403,183.492409 203.781503,183.605293 203.781503,185.840798" id="Fill-6" fill="#427B8A" fill-rule="nonzero"></path>
|
16
|
+
</g>
|
17
|
+
</g>
|
18
|
+
</g>
|
19
|
+
</svg>
|
data/renovate.json
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2019 Yegor Bugayenko
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
$stdout.sync = true
|
24
|
+
|
25
|
+
require 'simplecov'
|
26
|
+
SimpleCov.start
|
27
|
+
require 'minitest/autorun'
|
28
|
+
require_relative '../lib/zache'
|
data/test/test_zache.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# (The MIT License)
|
4
4
|
#
|
5
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
5
|
+
# Copyright (c) 2018-2023 Yegor Bugayenko
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -32,7 +32,7 @@ Thread.report_on_exception = true
|
|
32
32
|
|
33
33
|
# Cache test.
|
34
34
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
35
|
-
# Copyright:: Copyright (c) 2018 Yegor Bugayenko
|
35
|
+
# Copyright:: Copyright (c) 2018-2023 Yegor Bugayenko
|
36
36
|
# License:: MIT
|
37
37
|
class ZacheTest < Minitest::Test
|
38
38
|
def test_caches
|
@@ -74,6 +74,13 @@ class ZacheTest < Minitest::Test
|
|
74
74
|
assert(not_exists_result == false)
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_put_and_exists
|
78
|
+
cache = Zache.new
|
79
|
+
cache.put(:hey, 'hello', lifetime: 0.1)
|
80
|
+
sleep 0.2
|
81
|
+
assert(!cache.exists?(:hey))
|
82
|
+
end
|
83
|
+
|
77
84
|
def test_remove_key
|
78
85
|
cache = Zache.new
|
79
86
|
cache.get(:hey) { Random.rand }
|
data/zache.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# (The MIT License)
|
4
4
|
#
|
5
|
-
# Copyright (c) 2018 Yegor Bugayenko
|
5
|
+
# Copyright (c) 2018-2023 Yegor Bugayenko
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,14 +24,10 @@
|
|
24
24
|
|
25
25
|
require 'English'
|
26
26
|
Gem::Specification.new do |s|
|
27
|
-
s.
|
28
|
-
if s.respond_to? :required_rubygems_version=
|
29
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
30
|
-
end
|
31
|
-
s.rubygems_version = '2.5'
|
27
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
32
28
|
s.required_ruby_version = '>=2.5'
|
33
29
|
s.name = 'zache'
|
34
|
-
s.version = '0.
|
30
|
+
s.version = '0.13.0'
|
35
31
|
s.license = 'MIT'
|
36
32
|
s.summary = 'In-memory Cache'
|
37
33
|
s.description = 'Zero-footprint in-memory thread-safe cache'
|
@@ -39,14 +35,7 @@ Gem::Specification.new do |s|
|
|
39
35
|
s.email = 'yegor256@gmail.com'
|
40
36
|
s.homepage = 'http://github.com/yegor256/zache'
|
41
37
|
s.files = `git ls-files`.split($RS)
|
42
|
-
s.test_files = s.files.grep(%r{^(test)/})
|
43
38
|
s.rdoc_options = ['--charset=UTF-8']
|
44
39
|
s.extra_rdoc_files = ['README.md']
|
45
|
-
s.
|
46
|
-
s.add_development_dependency 'minitest', '5.11.3'
|
47
|
-
s.add_development_dependency 'rake', '12.3.1'
|
48
|
-
s.add_development_dependency 'rdoc', '4.3.0'
|
49
|
-
s.add_development_dependency 'rubocop', '0.62.0'
|
50
|
-
s.add_development_dependency 'rubocop-rspec', '1.31.0'
|
51
|
-
s.add_development_dependency 'threads', '0.3.0'
|
40
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
52
41
|
end
|
metadata
CHANGED
@@ -1,113 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: concurrent-ruby
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1.3
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.1.3
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 5.11.3
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 5.11.3
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 12.3.1
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 12.3.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rdoc
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 4.3.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 4.3.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.62.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.62.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop-rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.31.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.31.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: threads
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.3.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.3.0
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
111
13
|
description: Zero-footprint in-memory thread-safe cache
|
112
14
|
email: yegor256@gmail.com
|
113
15
|
executables: []
|
@@ -116,22 +18,29 @@ extra_rdoc_files:
|
|
116
18
|
- README.md
|
117
19
|
files:
|
118
20
|
- ".0pdd.yml"
|
21
|
+
- ".github/workflows/codecov.yml"
|
22
|
+
- ".github/workflows/pdd.yml"
|
23
|
+
- ".github/workflows/rake.yml"
|
24
|
+
- ".github/workflows/xcop.yml"
|
119
25
|
- ".gitignore"
|
120
26
|
- ".pdd"
|
121
27
|
- ".rubocop.yml"
|
122
28
|
- ".rultor.yml"
|
123
|
-
- ".travis.yml"
|
124
29
|
- Gemfile
|
30
|
+
- LICENSE.txt
|
125
31
|
- README.md
|
126
32
|
- Rakefile
|
127
|
-
- appveyor.yml
|
128
33
|
- lib/zache.rb
|
34
|
+
- logo.svg
|
35
|
+
- renovate.json
|
36
|
+
- test/test__helper.rb
|
129
37
|
- test/test_zache.rb
|
130
38
|
- zache.gemspec
|
131
39
|
homepage: http://github.com/yegor256/zache
|
132
40
|
licenses:
|
133
41
|
- MIT
|
134
|
-
metadata:
|
42
|
+
metadata:
|
43
|
+
rubygems_mfa_required: 'true'
|
135
44
|
post_install_message:
|
136
45
|
rdoc_options:
|
137
46
|
- "--charset=UTF-8"
|
@@ -148,9 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
57
|
- !ruby/object:Gem::Version
|
149
58
|
version: '0'
|
150
59
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.2.15
|
152
61
|
signing_key:
|
153
|
-
specification_version:
|
62
|
+
specification_version: 4
|
154
63
|
summary: In-memory Cache
|
155
|
-
test_files:
|
156
|
-
- test/test_zache.rb
|
64
|
+
test_files: []
|
data/.travis.yml
DELETED
data/appveyor.yml
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
version: '{build}'
|
2
|
-
skip_tags: true
|
3
|
-
clone_depth: 10
|
4
|
-
branches:
|
5
|
-
only:
|
6
|
-
- master
|
7
|
-
except:
|
8
|
-
- gh-pages
|
9
|
-
os: Windows Server 2012
|
10
|
-
environment:
|
11
|
-
matrix:
|
12
|
-
- ruby_version: "23-x64"
|
13
|
-
- ruby_version: "24-x64"
|
14
|
-
- ruby_version: "25-x64"
|
15
|
-
install:
|
16
|
-
- ps: |
|
17
|
-
$Env:PATH = "C:\Ruby${Env:ruby_version}\bin;${Env:PATH}"
|
18
|
-
if ($Env:ruby_version -match "^23" ) {
|
19
|
-
# RubyInstaller; download OpenSSL headers from OpenKnapsack Project
|
20
|
-
$Env:openssl_dir = "C:\Ruby${Env:ruby_version}"
|
21
|
-
appveyor DownloadFile http://dl.bintray.com/oneclick/OpenKnapsack/x64/openssl-1.0.2j-x64-windows.tar.lzma
|
22
|
-
7z e openssl-1.0.2j-x64-windows.tar.lzma
|
23
|
-
7z x -y -oC:\Ruby${Env:ruby_version} openssl-1.0.2j-x64-windows.tar
|
24
|
-
} else {
|
25
|
-
# RubyInstaller2; openssl package seems to be installed already
|
26
|
-
$Env:openssl_dir = "C:\msys64\mingw64"
|
27
|
-
}
|
28
|
-
- bundle config --local path vendor/bundle
|
29
|
-
- bundle config build.openssl --with-openssl-dir=%openssl_dir%
|
30
|
-
- ruby -v
|
31
|
-
- bundle -v
|
32
|
-
build_script:
|
33
|
-
- bundle update
|
34
|
-
- bundle install
|
35
|
-
test_script:
|
36
|
-
- bundle exec rake --quiet
|
37
|
-
cache:
|
38
|
-
- vendor/bundle
|