lock-smith 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/locksmith/dynamodb.rb +7 -3
- data/readme.md +2 -0
- metadata +1 -1
data/lib/locksmith/dynamodb.rb
CHANGED
@@ -45,12 +45,16 @@ module Locksmith
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def release_lock(name, rev)
|
48
|
-
locks.put({Name:
|
48
|
+
locks.put({Name: name, Locked: 0},
|
49
49
|
:if => {:Locked => rev})
|
50
50
|
end
|
51
51
|
|
52
52
|
def fetch_lock(name)
|
53
|
-
locks
|
53
|
+
if locks.at(name).exists?(consistent_read: true)
|
54
|
+
locks[name].attributes.to_h(consistent_read: true)
|
55
|
+
else
|
56
|
+
locks.put(Name: name, Locked: 0).attributes.to_h(consistent_read: true)
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
def locks
|
@@ -75,7 +79,7 @@ module Locksmith
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def log(data, &blk)
|
78
|
-
Log.log({ns: "
|
82
|
+
Log.log({ns: "dynamo-lock"}.merge(data), &blk)
|
79
83
|
end
|
80
84
|
|
81
85
|
end
|
data/readme.md
CHANGED