blunt-cache 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf46d74e7e4652dfef6b3f3b8a17ab2be7d6632f
4
- data.tar.gz: 299867f1138432a5de57407172c2388a57e13a70
3
+ metadata.gz: 36219a4ebbe5e011cfccc581cee7d60585f2cf96
4
+ data.tar.gz: b86c47768e3bc83ec119cc432aa08130998dccf5
5
5
  SHA512:
6
- metadata.gz: 6b6338db292321ea9f87384b4282e073285c331af8c66f2f7774bca89ffd1e5171524931ef952b3287739794a2ec421daf19296c296febf783b8e3d8db240801
7
- data.tar.gz: 27287a69808fb856764928b0105d24f91a055ab5b9b86b5a0ed907d3f59db0f8b0e62b698980616a0e4e6b5dac9436579d6e4627428fc2cb110501b40ec27d9a
6
+ metadata.gz: 74d110765ae9801c3d12368a40d9bceb9e7eae4e0bbc23b61412c22d03776d7650a092e12f431551142c65854bbb77d1047016b2febf90e95c0e122b2fcabcf1
7
+ data.tar.gz: 73025278992ede01a738c9b3185bd8615461c83077abee865149f97fd60718d4462c348b36207cefbf6ade24ef653d85bb114f762a89059e384a2538bcddb030
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1
9
+ - 2.2
10
+ - ree
11
+ - rbx
12
+ - jruby-18mode # JRuby in 1.8 mode
13
+ - jruby-19mode # JRuby in 1.9 mode
14
+
15
+ gemfile:
16
+ - Gemfile
17
+
18
+ sudo: false
19
+
20
+ script: "bundle exec rspec"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- blunt-cache (0.1.1)
4
+ blunt-cache (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -23,6 +23,7 @@ GEM
23
23
  rspec-support (3.3.0)
24
24
 
25
25
  PLATFORMS
26
+ java
26
27
  ruby
27
28
 
28
29
  DEPENDENCIES
@@ -30,3 +31,6 @@ DEPENDENCIES
30
31
  bundler (~> 1.6)
31
32
  rake (>= 10.0)
32
33
  rspec (~> 3.1)
34
+
35
+ BUNDLED WITH
36
+ 1.10.6
data/README.md CHANGED
@@ -36,4 +36,4 @@ Simple in-memory cache service for Ruby.
36
36
  ## Limitations
37
37
 
38
38
  * Keep in mind that values are stored in memory even if they are expired. As for replaced values, let's just belive in Ruby GC abilities. So, Ruby workers can bloat.
39
- * Keep in mind that Cache IS NOT shared between workers (e.g. Unicorn, Puma cluster workers) and IS shared between threads (Puma).
39
+ * Keep in mind that Cache IS NOT shared between workers (e.g. Unicorn, Puma cluster workers) and IS shared between threads (Puma).
@@ -1,3 +1,3 @@
1
1
  class BluntCache
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/blunt-cache.rb CHANGED
@@ -3,7 +3,9 @@ class BluntCache
3
3
  @expire_default = 60
4
4
 
5
5
  # Store +data+ in cache by +key+ for +:expire+ seconds (default is 60 sec)
6
- def self.set(key, data, expire: nil)
6
+ # def self.set(key, data, expire: nil)
7
+ def self.set(key, data, options = {}, *args)
8
+ expire = options[:expire]
7
9
  self.timestamp[key] = Time.now + (expire || self.expire_default)
8
10
  self.data[key] = data
9
11
  data
@@ -15,10 +17,12 @@ class BluntCache
15
17
  end
16
18
 
17
19
  # Get +key+ from cache. Executes +block+, stores it's result and returns it if not set or expired.
18
- def self.fetch(key, expire: nil, &block)
20
+ # def self.fetch(key, expire: nil, &block)
21
+ def self.fetch(key, options = {}, &block)
22
+ expire = options[:expire]
19
23
  result = self.get key
20
24
  if result.nil?
21
- self.set key, block.call, expire: expire
25
+ self.set key, block.call, :expire => expire
22
26
  else
23
27
  result
24
28
  end
@@ -28,7 +28,7 @@ describe BluntCache do
28
28
  end
29
29
 
30
30
  it 'returns value before expiration and nil after expiration' do
31
- expect { c.set("3", "3_val", expire: 0.1) }.not_to raise_error
31
+ expect { c.set("3", "3_val", :expire => 0.1) }.not_to raise_error
32
32
  result = nil
33
33
  expect { result = c.get("3") }.not_to raise_error
34
34
  expect(result).to eq "3_val"
@@ -52,7 +52,7 @@ describe BluntCache do
52
52
 
53
53
  it 'returns value before expiration and re-executes block after expiration (fetch)' do
54
54
  result = nil
55
- expect { result = c.fetch "6", expire: 0.1 do "6_val" end }.not_to raise_error
55
+ expect { result = c.fetch "6", :expire => 0.1 do "6_val" end }.not_to raise_error
56
56
  expect(result).to eq "6_val"
57
57
  expect { result = c.fetch "6" do "6_val_2" end }.not_to raise_error
58
58
  expect(result).to eq "6_val"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blunt-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Exempliarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".travis.yml"
63
64
  - Gemfile
64
65
  - Gemfile.lock
65
66
  - LICENSE
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  version: '0'
90
91
  requirements: []
91
92
  rubyforge_project:
92
- rubygems_version: 2.4.7
93
+ rubygems_version: 2.4.8
93
94
  signing_key:
94
95
  specification_version: 4
95
96
  summary: Simple in-memory cache service for Ruby.