Skip to content

Commit

Permalink
release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelser committed Apr 13, 2015
1 parent 1fd769e commit ce0a4d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.2.0

- Refactor class methods into instance methods to simplify implementation.
- Increase thread safety with Memcached implementation.

## 0.1.3

- Properly throw Suo::LockClientError when the connection itself fails (Memcache server not reachable, etc.)
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,22 @@ suo.lock("some_key") do
@puppies.pet!
end

2.times do
Thread.new do
# second argument is the number of resources - so this will run twice
suo.lock("other_key", 2, timeout: 0.5) { puts "Will run twice!" }
end
end
Thread.new { suo.lock("other_key", 2) { puts "One"; sleep 2 } }
Thread.new { suo.lock("other_key", 2) { puts "Two"; sleep 2 } }
Thread.new { suo.lock("other_key", 2) { puts "Three" } }

# will print "One" "Two", but not "Three", as there are only 2 resources

# custom acquisition timeouts (time to acquire)
suo = Suo::Client::Memcached.new(client: some_dalli_client, acquisition_timeout: 1) # in seconds

# manually locking/unlocking
suo.lock("a_key")
foo.baz!
suo.unlock("a_key")

# custom stale lock cleanup (cleaning of dead clients)
suo = Suo::Client::Redis.new(client: some_redis_client, stale_lock_expiration: 60*5)
```

## TODO
Expand Down
2 changes: 1 addition & 1 deletion lib/suo/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Suo
VERSION = "0.1.3"
VERSION = "0.2.0"
end

0 comments on commit ce0a4d8

Please sign in to comment.