h2ocube_rails_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: 4cd7e42662fab5ee8e21d1b70f625b6b3aa4479f
4
- data.tar.gz: d16b64b3fecb7423de4104f044e919cef318fde9
3
+ metadata.gz: 6310c11ac4f3f8f51739aa0093ec9ecddecda9a4
4
+ data.tar.gz: 2aef6c3682d61a6817ced4fd54ae9fd95da3609f
5
5
  SHA512:
6
- metadata.gz: 3d5457a47ad14fd7d6ad0e83f99644eb5ead5bb23555fef3e89ca0bfb8789e0fbbbb865374407162119c43eb6a262633b5eba98861244af49acffd3af2c16c43
7
- data.tar.gz: 451653df0beb426115ab363b48b717072f71ff7b3af2f1b1686708cbbda65b38cd5a4d8974c35c8f35a37962c6059361a664603782673b1590283cd8b02ea6a0
6
+ metadata.gz: e96f45ba648b840dbe501edfe48fc6e37a9e0b64c9129501f5e3b739831fcb059b16d11ee3c1693a8e4c60e8bb547fe159248028679007933f5e585199ae418b
7
+ data.tar.gz: 859d678430d4e2151dabfefb8c57df1c40105c3af1df27d37e833a499ee22ca3d6a194321e8129965b946c5a57efc1ecb1b9de57f62382334a83fab676da0325
data/README.md CHANGED
@@ -26,6 +26,7 @@ And then execute:
26
26
  * `exist? key, options = {}`
27
27
  * `increment key, amount = 1, options = {}`
28
28
  * `decrement key, amount = 1, options = {}`
29
+ * `expire time`
29
30
  * `clear`
30
31
  * `info`
31
32
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = 'h2ocube_rails_cache'
7
- gem.version = '0.1.1'
7
+ gem.version = '0.1.2'
8
8
  gem.authors = ['Ben']
9
9
  gem.email = ['ben@h2ocube.com']
10
10
  gem.description = 'Just an redis cache.'
@@ -124,6 +124,15 @@ module ActiveSupport
124
124
  @data.info
125
125
  end
126
126
 
127
+ def expire(key, expires_in)
128
+ options.reverse_merge! config
129
+ key = normalize_key key, options
130
+
131
+ instrument :expire, key, expires_in: expires_in.to_i do
132
+ @data.expire key, expires_in.to_i
133
+ end
134
+ end
135
+
127
136
  def increment(key, amount = 1, options = {})
128
137
  options.reverse_merge! config
129
138
  key = normalize_key key, options
data/test/cache_test.rb CHANGED
@@ -32,7 +32,7 @@ describe 'h2ocube_rails_cache' do
32
32
  Rails.cache.read('a').must_be_nil
33
33
  end
34
34
 
35
- it 'expire' do
35
+ it '#write expire' do
36
36
  Rails.cache.delete 'expire'
37
37
  Rails.cache.write 'expire', true, expires_in: 1.second
38
38
  Rails.cache.exist?('expire').must_be_same_as true
@@ -40,6 +40,14 @@ describe 'h2ocube_rails_cache' do
40
40
  Rails.cache.exist?('expire').must_be_same_as false
41
41
  end
42
42
 
43
+ it '#expire' do
44
+ Rails.cache.write 'expire', true
45
+ Rails.cache.expire 'expire', 1.second
46
+ Rails.cache.exist?('expire').must_be_same_as true
47
+ sleep 2
48
+ Rails.cache.exist?('expire').must_be_same_as false
49
+ end
50
+
43
51
  it 'key class' do
44
52
  Rails.cache.write ['a', 0], 'a0'
45
53
  Rails.cache.keys[0].must_equal "#{Rails.cache.config[:namespace]}:a/0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2ocube_rails_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
  - Ben
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-17 00:00:00.000000000 Z
11
+ date: 2017-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis