rediska 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c489cb0bfa35be708f1ff38c4d6dc8752e82ee48
4
- data.tar.gz: 6aa8a958e914fd825422bf69a241df30281d56b5
3
+ metadata.gz: 919caed5a31e25a55da2f469c2edc1c547324bfc
4
+ data.tar.gz: c85a871a9c4713e1a57b789ef5cb9e27a1241d89
5
5
  SHA512:
6
- metadata.gz: 6d413303c1a0756a170f028ad8551b6eaf5f0200071ca404233d1073bc9568dcd0e359a5f36ac54625e5824eb130e36d058c2877ce74e066e5bf9a2953ffa1bc
7
- data.tar.gz: 4b0256a2c42db9227cb15d6858eaf6161acaa3a241303de096c22db28b20dbbe503860f9f6b92d99d3ce2c01f45d992f3dcba75f2c4dc9bb1f860029b46bf7ae
6
+ metadata.gz: fed6d70e8c5864712501cb2301297aea5be21a0eb5df1b0a355a9740bcfce7d3164e27257a864f9b31094941934ae6b4b6922155fa374458d8f0b0ccd76fad09
7
+ data.tar.gz: f8518a36ca7b79adc805c090afd6af06cdb4b6981bcee3ad208c75236e59b7edc79078964e851799abe84fb48ad1bdd631b20872c547e50a826f48048aa67654
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rediska (0.2.2)
4
+ rediska (0.2.3)
5
5
  redis (>= 3)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- celluloid (0.15.2)
11
- timers (~> 1.1.0)
12
- connection_pool (2.0.0)
10
+ celluloid (0.16.0)
11
+ timers (~> 4.0.0)
12
+ connection_pool (2.1.0)
13
13
  coveralls (0.7.2)
14
14
  multi_json (~> 1.3)
15
15
  rest-client (= 1.6.7)
@@ -18,6 +18,7 @@ GEM
18
18
  thor (= 0.18.1)
19
19
  diff-lcs (1.2.5)
20
20
  docile (1.1.5)
21
+ hitimes (1.2.2)
21
22
  json (1.8.1)
22
23
  mime-types (2.4.3)
23
24
  multi_json (1.10.1)
@@ -41,8 +42,8 @@ GEM
41
42
  rspec-mocks (3.1.3)
42
43
  rspec-support (~> 3.1.0)
43
44
  rspec-support (3.1.2)
44
- sidekiq (3.2.6)
45
- celluloid (= 0.15.2)
45
+ sidekiq (3.3.0)
46
+ celluloid (>= 0.16.0)
46
47
  connection_pool (>= 2.0.0)
47
48
  json
48
49
  redis (>= 3.0.6)
@@ -55,7 +56,8 @@ GEM
55
56
  term-ansicolor (1.2.2)
56
57
  tins (~> 0.8)
57
58
  thor (0.18.1)
58
- timers (1.1.0)
59
+ timers (4.0.1)
60
+ hitimes
59
61
  tins (0.13.2)
60
62
 
61
63
  PLATFORMS
@@ -507,6 +507,14 @@ module Rediska
507
507
  1
508
508
  end
509
509
 
510
+ def pexpire(key, ttl)
511
+ return 0 unless data[key]
512
+
513
+ data.expires[key] = Time.now + (ttl / 1000.0)
514
+
515
+ 1
516
+ end
517
+
510
518
  def ttl(key)
511
519
  if data.expires.include?(key) && (ttl = data.expires[key].to_i - Time.now.to_i) > 0
512
520
  ttl
@@ -515,6 +523,14 @@ module Rediska
515
523
  end
516
524
  end
517
525
 
526
+ def pttl(key)
527
+ if data.expires.include?(key) && (ttl = data.expires[key].to_f - Time.now.to_f) > 0
528
+ ttl * 1000
529
+ else
530
+ exists(key) ? -1 : -2
531
+ end
532
+ end
533
+
518
534
  def expireat(key, timestamp)
519
535
  data.expires[key] = Time.at(timestamp)
520
536
  true
@@ -1,3 +1,3 @@
1
1
  module Rediska
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  end
data/spec/support/keys.rb CHANGED
@@ -40,6 +40,16 @@ shared_examples 'keys' do
40
40
  expect(subject.expire('key1', 1)).to be_truthy
41
41
  end
42
42
 
43
+ it 'should return true when setting pexpires on keys that exist' do
44
+ subject.set('key1', '1')
45
+ expect(subject.pexpire('key1', 1)).to be_truthy
46
+ end
47
+
48
+ it 'should return true when setting pexpires on keys that exist' do
49
+ subject.set('key1', '1')
50
+ expect(subject.pexpire('key1', 1)).to be_truthy
51
+ end
52
+
43
53
  it 'should return false when attempting to set expires on a key that does not exist' do
44
54
  expect(subject.expire('key1', 1)).to be_falsey
45
55
  end
@@ -58,7 +68,13 @@ shared_examples 'keys' do
58
68
  expect(subject.ttl('key1')).to eq(1)
59
69
  end
60
70
 
61
- it "should set the expiration for a key as a UNIX timestamp" do
71
+ it "should set a key's time to live in miliseconds" do
72
+ subject.set('key1', '1')
73
+ subject.pexpire('key1', 2200)
74
+ expect(subject.pttl('key1')).to be_within(0.5).of(2200)
75
+ end
76
+
77
+ it 'should set the expiration for a key as a UNIX timestamp' do
62
78
  subject.set('key1', '1')
63
79
  subject.expireat('key1', Time.now.to_i + 100)
64
80
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rediska
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis