Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
samcook committed Jul 29, 2015
1 parent f761d5f commit 396cd17
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RedLock.net is available using NuGet - search for [RedLock.net](https://www.nuge

## Usage

Construct a `RedisLockFactory`, passing in a set of independent Redis endpoints. The Redis endpoints should be independent (i.e. not replicated masters/slaves).
Construct a `RedisLockFactory`, passing in a set of 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.

Expand All @@ -29,6 +29,8 @@ var endPoints = new[]
var redisLockFactory = new RedisLockFactory(endPoints);
```

If you require more detailed configuration for the redis instances you are connecting to (e.g. password, SSL, connection timeout), you can use the `RedisLockEndPoint` class.

#### When you want to lock on a resource (giving up immediately if the lock is not available):
```csharp
var resource = "the-thing-we-are-locking-on";
Expand Down Expand Up @@ -64,24 +66,18 @@ using (var redisLock = redisLockFactory.Create(resource, expiry, wait, retry))
// the lock is automatically released at the end of the using block
```


#### To use a Azure Redis Cache service connection:
```csharp
var azureRedisEndpoint = new AzureRedisCacheEndpoint
{
Host = "YOUR_CACHE.redis.cache.windows.net",
AccessKey = "YOUR_ACCESS_KEY",
SSL = true
};

using (var redisLockFactory = new RedisLockFactory(azureRedisEndpoint))
{
// do stuff
}
```


#### On app shutdown:
```csharp
redisLockFactory.Dispose();
```

#### Azure Redis Cache:
If you are connecting to Azure Redis Cache, use the following configuration settings:
```csharp
var azureEndPoint = new RedisLockEndPoint
{
EndPoint = new DnsEndPoint("YOUR_CACHE.redis.cache.windows.net", 6380),
Password = "YOUR_ACCESS_KEY",
Ssl = true
};
```

0 comments on commit 396cd17

Please sign in to comment.