once 0.0.3 → 0.0.4

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: bc1dc66aa1467c67d46b20d62737dce0c95dc307
4
- data.tar.gz: 18db88e365f371eab21b2bca55348e2db40d1f68
3
+ metadata.gz: dde9027d041ec8bc455dfb29b458fed3666da33e
4
+ data.tar.gz: 1bb7239b043139e3da69164c09bf9a50ac075aad
5
5
  SHA512:
6
- metadata.gz: 1c3ef2cc6f39da8ee988767b3af06872086ced4f20639d4c356ca7893169e328d73bad675aa3b227ea3993695d8ec90c6351ecd98c65ad695001aab0c5d8e25f
7
- data.tar.gz: c79340580c1018db34d175055d48170a3300388e03b84c5d205456da408512fbdcc5213ec2512aa39cb61999e609075d28f553aed2920e52b845527298206031
6
+ metadata.gz: 2a0691f67c45f58704d86663a0a8bff8ae2230a2f0d009babdb6f8adb4ba9879d94dd879ac0565dd4c31fb88a94d48e4fa6285d409cf28c7bd7046bfa9e36378
7
+ data.tar.gz: 45afe0ac8fbdfc7166330f8263c990ddb358def0174956392345d96d5f2fe2457a1832258d0a2b3d8483c350b41b5568448c7f404862b0698fcf452bab61b809
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.0.4
2
+ * Fully atomic using setnx
3
+
1
4
  ## 0.0.3
2
5
  * Atomic setex insted of set and expire commands individually
3
6
  * Return results of the executed block
data/lib/once.rb CHANGED
@@ -37,15 +37,7 @@ module Once
37
37
  hash = Digest::MD5.hexdigest(params.inspect)
38
38
  redis_key = "uniquecheck:#{name}:#{hash}"
39
39
 
40
- perform(redis_key, &block).tap do
41
- redis.setex(redis_key, within, true)
42
- end
43
- end
44
-
45
- private
46
-
47
- def perform(redis_key, &block)
48
- unless redis.exists(redis_key)
40
+ if redis.set(redis_key, true, ex: within, nx: true)
49
41
  block.call
50
42
  end
51
43
  end
data/lib/once/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Once
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: once
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yan Pritzker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2017-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler