legion-cache 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/.rakeTasks +7 -0
- data/.idea/legion-cache.iml +36 -0
- data/.idea/misc.xml +7 -0
- data/.idea/modules.xml +8 -0
- data/.idea/vagrant.xml +7 -0
- data/.idea/workspace.xml +14 -0
- data/Gemfile +0 -2
- data/lib/legion/cache/memcached.rb +5 -8
- data/lib/legion/cache/redis.rb +9 -6
- data/lib/legion/cache/settings.rb +9 -7
- data/lib/legion/cache/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8af525a0967b0fd5cb1ac712c7e34a61d33328928713a89a1dbe2126e3100884
|
4
|
+
data.tar.gz: e08cdd2f12067cb126d5060d1d9230b8460650c5e69825067c51bf2d16fe6588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a91fd392e2d2eb6b02ae7e38d2dedc05841dc86f64cd829222c84b8c4a3d547e2db544fb57f93bbdd3fc2b121667e8fe27d5431b5bdd21182c82d190b9892da
|
7
|
+
data.tar.gz: a35558df6bec660463bafa24093cd383b522d4436d4cd69f5b0d1b4287949df08c8ccefd4783535a98bfb086b91358498b936e23ef682459ac540ac830abc706
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build legion-cache-0.2.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install legion-cache-0.2.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install legion-cache-0.2.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.2.0 and build and push legion-cache-0.2.0.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="ModuleRunConfigurationManager">
|
4
|
+
<shared />
|
5
|
+
</component>
|
6
|
+
<component name="NewModuleRootManager">
|
7
|
+
<content url="file://$MODULE_DIR$" />
|
8
|
+
<orderEntry type="inheritedJdk" />
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="connection_pool (v2.2.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="dalli (v2.7.10, RVM: ruby-2.6.3) [gem]" level="application" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.3.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="jaro_winkler (v1.5.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="legion-logging (v0.2.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.19.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="parser (v2.7.0.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="redis (v4.1.3, RVM: ruby-2.6.3) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.4, RVM: ruby-2.6.3) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.9.0, RVM: ruby-2.6.3) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.9.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.9.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec_junit_formatter (v0.4.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop (v0.80.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.10.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.18.5, RVM: ruby-2.6.3) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.2, RVM: ruby-2.6.3) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.6.1, RVM: ruby-2.6.3) [gem]" level="application" />
|
35
|
+
</component>
|
36
|
+
</module>
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="JavaScriptSettings">
|
4
|
+
<option name="languageLevel" value="ES6" />
|
5
|
+
</component>
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.6.3" project-jdk-type="RUBY_SDK" />
|
7
|
+
</project>
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/legion-cache.iml" filepath="$PROJECT_DIR$/.idea/legion-cache.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
data/.idea/vagrant.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="CoverageOptionsProvider">
|
4
|
+
<option name="myAddOrReplace" value="0" />
|
5
|
+
</component>
|
6
|
+
<component name="Git.Settings">
|
7
|
+
<option name="PUSH_AUTO_UPDATE" value="true" />
|
8
|
+
<option name="ROOT_SYNC" value="DONT_SYNC" />
|
9
|
+
</component>
|
10
|
+
<component name="ProjectId" id="1Yl3LLXb9c4jt3mof9hHMP78fdY" />
|
11
|
+
<component name="PropertiesComponent">
|
12
|
+
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.project.vagrant" />
|
13
|
+
</component>
|
14
|
+
</project>
|
data/Gemfile
CHANGED
@@ -5,12 +5,9 @@ module Legion
|
|
5
5
|
module Memcached
|
6
6
|
def connect
|
7
7
|
Legion::Logging.debug 'Using Memcached module for Legion::Cache'
|
8
|
-
|
9
|
-
serializer: Legion::JSON,
|
10
|
-
failover: Legion::Settings[:cache][:failover],
|
11
|
-
namespace: Legion::Settings[:cache][:namespace], foo: 'test' }
|
8
|
+
|
12
9
|
Dalli.logger = Legion::Logging
|
13
|
-
@client = Dalli::Client.new(Legion::Settings[:cache][:servers],
|
10
|
+
@client = Dalli::Client.new(Legion::Settings[:cache][:servers], Legion::Settings[:cache])
|
14
11
|
Legion::Logging.debug "Legion::Cache successfully connected to #{Legion::Settings[:cache][:servers]}"
|
15
12
|
Legion::Settings[:cache][:connected] = true
|
16
13
|
end
|
@@ -33,15 +30,15 @@ module Legion
|
|
33
30
|
end
|
34
31
|
|
35
32
|
def set(key, value, ttl = 180)
|
36
|
-
@client.set(key, value, ttl)
|
33
|
+
@client.set(key, value, ttl).positive?
|
37
34
|
end
|
38
35
|
|
39
36
|
def delete(key)
|
40
|
-
@client.delete(key)
|
37
|
+
@client.delete(key) == true
|
41
38
|
end
|
42
39
|
|
43
40
|
def flush(delay = 0)
|
44
|
-
@client.flush(delay)
|
41
|
+
@client.flush(delay).first
|
45
42
|
end
|
46
43
|
end
|
47
44
|
end
|
data/lib/legion/cache/redis.rb
CHANGED
@@ -4,7 +4,7 @@ module Legion
|
|
4
4
|
module Cache
|
5
5
|
module Redis
|
6
6
|
def connect
|
7
|
-
@client = Redis.new
|
7
|
+
@client = ::Redis.new
|
8
8
|
end
|
9
9
|
|
10
10
|
def close
|
@@ -17,19 +17,22 @@ module Legion
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get(key)
|
20
|
-
@client
|
20
|
+
@client.get(key)
|
21
21
|
end
|
22
|
+
alias fetch get
|
22
23
|
|
23
|
-
def set(key, value)
|
24
|
-
|
24
|
+
def set(key, value, ttl: nil)
|
25
|
+
args = {}
|
26
|
+
args[:ex] = ttl unless ttl.nil?
|
27
|
+
@client.set(key, value, **args) == 'OK'
|
25
28
|
end
|
26
29
|
|
27
30
|
def delete(key)
|
28
|
-
@client.del
|
31
|
+
@client.del(key) == 1
|
29
32
|
end
|
30
33
|
|
31
34
|
def flush
|
32
|
-
@client.flushdb
|
35
|
+
@client.flushdb == 'OK'
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Legion
|
2
2
|
module Cache
|
3
3
|
module Settings
|
4
|
+
Legion::Settings.merge_settings(:cache, default) if Legion::Settings.method_defined? :merge_settings
|
4
5
|
def self.default
|
5
6
|
{
|
6
|
-
driver:
|
7
|
+
driver: driver,
|
7
8
|
servers: ['127.0.0.1:11211'],
|
8
9
|
connected: false,
|
9
10
|
enabled: true,
|
@@ -13,16 +14,17 @@ module Legion
|
|
13
14
|
threadsafe: true,
|
14
15
|
expires_in: 0,
|
15
16
|
cache_nils: false,
|
16
|
-
pool_size:
|
17
|
+
pool_size: 5,
|
17
18
|
serializer: Legion::JSON
|
18
19
|
}
|
19
20
|
end
|
20
21
|
|
21
|
-
def self.driver
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def self.driver(prefer = 'dalli')
|
23
|
+
secondary = prefer == 'dalli' ? 'redis' : 'dalli'
|
24
|
+
if Gem::Specification.find_all_by_name(prefer).count.positive?
|
25
|
+
prefer
|
26
|
+
elsif Gem::Specification.find_all_by_name(secondary).count.positive?
|
27
|
+
secondary
|
26
28
|
else
|
27
29
|
raise NameError('Legion::Cache.driver is nil')
|
28
30
|
end
|
data/lib/legion/cache/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: legion-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esity
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -173,6 +173,12 @@ extra_rdoc_files: []
|
|
173
173
|
files:
|
174
174
|
- ".circleci/config.yml"
|
175
175
|
- ".gitignore"
|
176
|
+
- ".idea/.rakeTasks"
|
177
|
+
- ".idea/legion-cache.iml"
|
178
|
+
- ".idea/misc.xml"
|
179
|
+
- ".idea/modules.xml"
|
180
|
+
- ".idea/vagrant.xml"
|
181
|
+
- ".idea/workspace.xml"
|
176
182
|
- ".rspec"
|
177
183
|
- ".rubocop.yml"
|
178
184
|
- Gemfile
|
@@ -211,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
217
|
- !ruby/object:Gem::Version
|
212
218
|
version: '0'
|
213
219
|
requirements: []
|
214
|
-
rubygems_version: 3.0.
|
220
|
+
rubygems_version: 3.0.8
|
215
221
|
signing_key:
|
216
222
|
specification_version: 4
|
217
223
|
summary: Legion::Cache integration
|