mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af1c476f08 | ||
|
|
58fae54022 | ||
|
|
2088fd90b3 | ||
|
|
05661e143c |
@@ -74,7 +74,7 @@ Style/SpaceInsideBrackets:
|
|||||||
Style/AndOr:
|
Style/AndOr:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
Style/TrailingComma:
|
Style/TrailingCommaInLiteral:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Style/SpaceBeforeComma:
|
Style/SpaceBeforeComma:
|
||||||
@@ -98,7 +98,7 @@ Style/SpaceAfterColon:
|
|||||||
Style/SpaceAfterComma:
|
Style/SpaceAfterComma:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Style/SpaceAfterControlKeyword:
|
Style/SpaceAroundKeyword:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
Style/SpaceAfterNot:
|
Style/SpaceAfterNot:
|
||||||
@@ -163,7 +163,7 @@ Style/StringLiterals:
|
|||||||
EnforcedStyle: double_quotes
|
EnforcedStyle: double_quotes
|
||||||
|
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Max: 8
|
Max: 10
|
||||||
|
|
||||||
Metrics/LineLength:
|
Metrics/LineLength:
|
||||||
Max: 128
|
Max: 128
|
||||||
@@ -214,3 +214,6 @@ Metrics/ParameterLists:
|
|||||||
|
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
|
Style/Documentation:
|
||||||
|
Enabled: false
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
language: ruby
|
language: ruby
|
||||||
rvm:
|
rvm:
|
||||||
- 2.2.0
|
- 2.2.0
|
||||||
|
- 2.3.1
|
||||||
services:
|
services:
|
||||||
- memcached
|
- memcached
|
||||||
- redis-server
|
- redis-server
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
## 0.3.2
|
||||||
|
|
||||||
|
- Custom lock tokens (thanks to avokhmin).
|
||||||
|
|
||||||
## 0.3.1
|
## 0.3.1
|
||||||
|
|
||||||
- Slight memory leak fix.
|
- Slight memory leak fix.
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ module Suo
|
|||||||
super() # initialize Monitor mixin for thread safety
|
super() # initialize Monitor mixin for thread safety
|
||||||
end
|
end
|
||||||
|
|
||||||
def lock
|
def lock(custom_token = nil)
|
||||||
token = acquire_lock
|
token = acquire_lock(custom_token)
|
||||||
|
|
||||||
if block_given? && token
|
if block_given? && token
|
||||||
begin
|
begin
|
||||||
@@ -95,8 +95,8 @@ module Suo
|
|||||||
|
|
||||||
attr_accessor :retry_count
|
attr_accessor :retry_count
|
||||||
|
|
||||||
def acquire_lock
|
def acquire_lock(token = nil)
|
||||||
token = SecureRandom.base64(16)
|
token ||= SecureRandom.base64(16)
|
||||||
|
|
||||||
retry_with_timeout do
|
retry_with_timeout do
|
||||||
val, cas = get
|
val, cas = get
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module Suo
|
module Suo
|
||||||
VERSION = "0.3.1"
|
VERSION = "0.3.2".freeze
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ module ClientTests
|
|||||||
assert_equal false, locked
|
assert_equal false, locked
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_lock_with_custom_token
|
||||||
|
token = 'foo-bar'
|
||||||
|
lock = @client.lock token
|
||||||
|
assert_equal lock, token
|
||||||
|
end
|
||||||
|
|
||||||
def test_empty_lock_on_invalid_data
|
def test_empty_lock_on_invalid_data
|
||||||
@client.send(:initial_set, "bad value")
|
@client.send(:initial_set, "bad value")
|
||||||
assert_equal false, @client.locked?
|
assert_equal false, @client.locked?
|
||||||
|
|||||||
Reference in New Issue
Block a user