diff --git a/README.md b/README.md index 057ee73..600f5d5 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,13 @@ Makes use of the excellent [StackExchange.Redis](https://github.com/StackExchang Distributed locks are useful for ensuring only one process is using a particular resource at any given time (even if the processes are running on different machines). +RedLock.net is available using NuGet - search for [RedLock.net](https://www.nuget.org/packages/RedLock.net) (you'll need to enable pre-release packages at this point). + ## Usage -Construct a `RedisLockFactory` (passing in a set of redis endpoints). You should keep hold of this and reuse it in your application. Each instance of `RedisLockFactory` maintains its own set of connections with Redis. Remember to dispose it when your app shuts down. +Construct a `RedisLockFactory`, passing in a set of independent Redis endpoints. The Redis endpoints should be independent (i.e. not replicated masters/slaves). + +You should keep hold of the `RedisLockFactory` and reuse it in your application. Each instance maintains its own connections with the configured Redis instances. Remember to dispose it when your app shuts down. With the factory, create a `RedisLock` in a using block, making sure to check that that the lock `IsAcquired` inside the block before performing any actions. A lock is acquired if `RedisLock` can set a lock key in more than half of the redis instances. @@ -16,6 +20,12 @@ Internally `RedisLock` has a timer that automatically tries to keep the redis lo #### On app init: ```csharp +var endPoints = new[] +{ + new DnsEndPoint("redis1", 6379), + new DnsEndPoint("redis2", 6379), + new DnsEndPoint("redis3", 6379) +}; var redisLockFactory = new RedisLockFactory(endPoints); ``` @@ -42,6 +52,7 @@ var expiry = TimeSpan.FromSeconds(30); var wait = TimeSpan.FromSeconds(10); var retry = TimeSpan.FromSeconds(1); +// blocks until acquired or 'wait' timeout using (var redisLock = redisLockFactory.Create(resource, expiry, wait, retry)) { // make sure we got the lock diff --git a/RedLock/Properties/AssemblyInfo.cs b/RedLock/Properties/AssemblyInfo.cs index 619010f..364d801 100644 --- a/RedLock/Properties/AssemblyInfo.cs +++ b/RedLock/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("RedLock.net")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("An implementation of the Redlock distributed lock algorithm")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("RedLock.net")] @@ -32,7 +32,8 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyInformationalVersion("1.0.0-alpha")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: InternalsVisibleTo("RedLock.Tests")] \ No newline at end of file diff --git a/RedLock/RedLock.csproj b/RedLock/RedLock.csproj index aaac7c8..3cc6477 100644 --- a/RedLock/RedLock.csproj +++ b/RedLock/RedLock.csproj @@ -52,6 +52,7 @@ + + false + An implementation of the Redlock distributed lock algorithm + 1.0.0 - Initial release + Copyright 2014 Sam Cook + RedLock Redis Distributed Lock + + \ No newline at end of file