-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
The URP SDK exposes the class UnifiedConnectionMultiplexer which implements IConnectionMultiplexer class from StackExchange.Redis library. This class can be used to connect to the Redis Cluster. In the most general scenario 4 parameters are needed to connect to the cluster
- Cluster ID – This is the ID of the cluster to which the application has been registered.
- Application ID – This is a unique ID generated for your application
- App Key – A secret is generated for each application which is used for authentication
- [Options] Location – The location of the client application can either be specified when connecting to the cluster. If left blank, then the location is auto detected.
IConnectionMultiplexer _mux = UnifiedConnectionMultiplexer.Connect(_clusterName, _appName, _appSecret, preferredLocation: _location);
All existing operations available on IConnectionMultiplexer is also available on UnifiedConnectionMultiplexer.
Once the connection to the cluster has been established the next step is to create an instance of the Redis Database to perform the required operations. URP SDK exposes the UnifiedRedisDatabase class which is implemented from IDatabase of StackExchange.Redis library, thus providing all operations in StackExchange.Redis. IDatabase _database = _mux.GetDatabase(); All operations available on IDatabase can now be performed. Note that the client application need not add any prefix to the keys, the prefix addition is abstracted and will be taken care by the application. A few examples of using the IDatabase are given below:
await _database.StringSetAsync(keyName, value);
var value = await _database.StringGetAsync(keyName);
To see a full list of operations available in StackExchage.Redis library please check the official documentation of StackExchage.Redis.