mirror of
https://github.com/dkam/suo.git
synced 2025-01-29 07:42:43 +00:00
remove semaphore language and clarify language
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
## 0.1.1
|
## 0.1.1
|
||||||
|
|
||||||
- Use [MessagePack](https://github.com/msgpack/msgpack-ruby) for semaphore serialization.
|
- Use [MessagePack](https://github.com/msgpack/msgpack-ruby) for lock serialization.
|
||||||
|
|
||||||
## 0.1.0
|
## 0.1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Suo [](https://travis-ci.org/nickelser/suo) [](https://codeclimate.com/github/nickelser/suo) [](https://codeclimate.com/github/nickelser/suo) [](http://badge.fury.io/rb/suo)
|
# Suo [](https://travis-ci.org/nickelser/suo) [](https://codeclimate.com/github/nickelser/suo) [](https://codeclimate.com/github/nickelser/suo) [](http://badge.fury.io/rb/suo)
|
||||||
|
|
||||||
:lock: Distributed semaphores using Memcached or Redis in Ruby.
|
:lock: Distributed locks using Memcached or Redis in Ruby.
|
||||||
|
|
||||||
Suo provides a very performant distributed lock solution using Compare-And-Set (`CAS`) commands in Memcached, and `WATCH/MULTI` in Redis.
|
Suo provides a very performant distributed lock solution using Compare-And-Set (`CAS`) commands in Memcached, and `WATCH/MULTI` in Redis. It allows locking both single exclusion (a mutex - sharing one resource), and multiple resources.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ suo.lock("some_key") do
|
|||||||
@puppies.pet!
|
@puppies.pet!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# The second argument to lock is the number of arguments (defaulting to one - a mutex)
|
||||||
Thread.new { suo.lock("other_key", 2) { puts "One"; sleep 2 } }
|
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 "Two"; sleep 2 } }
|
||||||
Thread.new { suo.lock("other_key", 2) { puts "Three" } }
|
Thread.new { suo.lock("other_key", 2) { puts "Three" } }
|
||||||
@@ -69,6 +70,10 @@ suo.lock("foo") do |lock|
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Semaphore
|
||||||
|
|
||||||
|
With multiple resources, Suo acts like a semaphore, but is not strictly a semaphore according to the traditional definition, as the lock acquires ownership.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- more race condition tests
|
- more race condition tests
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|||||||
spec.authors = ["Nick Elser"]
|
spec.authors = ["Nick Elser"]
|
||||||
spec.email = ["nick.elser@gmail.com"]
|
spec.email = ["nick.elser@gmail.com"]
|
||||||
|
|
||||||
spec.summary = %q(Distributed semaphores using Memcached or Redis.)
|
spec.summary = %q(Distributed locks using Memcached or Redis.)
|
||||||
spec.description = %q(Distributed semaphores using Memcached or Redis.)
|
spec.description = %q(Distributed locks using Memcached or Redis.)
|
||||||
spec.homepage = "https://github.com/nickelser/suo"
|
spec.homepage = "https://github.com/nickelser/suo"
|
||||||
spec.license = "MIT"
|
spec.license = "MIT"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user