Support of Redis for .NET
CAST supports Redis via its com.castsoftware.nosqldotnet extension. Details about the support provided for .NET source code is discussed below.
Supported Client Libraries
Library | Supported |
---|---|
StackExchange.Redis | |
ServiceStack.Redis | |
Microsoft.Extensions.Caching.Redis | |
Microsoft.Extensions.Caching.StackExchangeRedis |
Supported Operations
Operation | Scenario | Methods Supported |
---|---|---|
Insert | StackExchange.Redis | StackExchange.Redis.IDatabase.StringSet StackExchange.Redis.IDatabaseAsync.StringSetAsync StackExchange.Redis.IDatabase.Add StackExchange.Redis.IDatabase.GeoAdd' StackExchange.Redis.IDatabase.HashSet StackExchange.Redis.IDatabase.SetCombineAndStore |
Insert | ServiceStack.Redis | ServiceStack.Redis.RedisClient.AddItemToList ServiceStack.Redis.RedisClient.AddItemToSet ServiceStack.Redis.RedisClient.AddRangeToList ServiceStack.Redis.RedisClient.AddRangeToSet ServiceStack.Redis.RedisClient.CreateHashSet ServiceStack.Redis.RedisClient.PushItemToList |
Insert | Microsoft.Extensions.Caching.Redis | Microsoft.Extensions.Caching.Redis.RedisCache.Set Microsoft.Extensions.Caching.Redis.RedisCache.SetAsync |
Insert | Microsoft.Extensions.Caching.StackExchangeRedis | Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Set Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.SetAsync |
Update | StackExchange.Redis | StackExchange.Redis.IDatabase.StringIncrement StackExchange.Redis.IDatabaseAsync.StringIncrementAsync StackExchange.Redis.IDatabase.KeyMigrate |
Update | ServiceStack.Redis | ServiceStack.Redis.RedisClient.IncrementValueInHash |
Select | StackExchange.Redis | StackExchange.Redis.IDatabase.StringGet StackExchange.Redis.IDatabaseAsync.StringGetAsync StackExchange.Redis.IDatabase.GeoRadius StackExchange.Redis.IDatabaseAsync.GeoRadiusAsync StackExchange.Redis.IDatabaseAsync.HashGetAllAsync StackExchange.Redis.IDatabase.HashGetAll StackExchange.Redis.IDatabase.HashScan StackExchange.Redis.IDatabase.SetScan StackExchange.Redis.IDatabase.Get StackExchange.Redis.IDatabase.HashExists StackExchange.Redis.IDatabase.SetCombineAndStore |
Select | ServiceStack.Redis | ServiceStack.Redis.RedisClient.GetHashCount ServiceStack.Redis.RedisClient.GetHashKeys ServiceStack.Redis.RedisClient.GetListCount ServiceStack.Redis.RedisClient.GetSetCount |
Select | Microsoft.Extensions.Caching.Redis |
Microsoft.Extensions.Caching.Redis.RedisCache.Get Microsoft.Extensions.Caching.Redis.RedisCache.GetAsync Microsoft.Extensions.Caching.Redis.RedisCache.GetAndRefresh Microsoft.Extensions.Caching.Redis.RedisCache.GetAndRefreshAsync |
Select | Microsoft.Extensions.Caching.StackExchangeRedis | Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Get Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAsync Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAndRefresh Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAndRefreshAsync |
Delete | StackExchange.Redis | StackExchange.Redis.IDatabase.KeyDelete StackExchange.Redis.IDatabase.Remove StackExchange.Redis.IDatabase.RemoveAll StackExchange.Redis.IDatabase.KeyDump |
Delete | ServiceStack.Redis | ServiceStack.Redis.RedisClient.RemoveItemFromSet ServiceStack.Redis.RedisClient.RemoveItemFromList ServiceStack.Redis.RedisClient.PopItemFromList |
Delete | Microsoft.Extensions.Caching.Redis | Microsoft.Extensions.Caching.Redis.RedisCache.Remove Microsoft.Extensions.Caching.Redis.RedisCache.RemoveAsync |
Delete | Microsoft.Extensions.Caching.StackExchangeRedis | Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.Remove Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.RemoveAsync |
Objects
Icon | Description |
---|---|
DotNet Redis Connection | |
DotNet Redis Collection | |
DotNet Unknown Redis Connection | |
|
DotNet Unknown Redis Collection |
Links
Links are created for transaction and function point needs:
Link type | Source and destination of link | Methods supported |
---|---|---|
belongsTo | From DotNet Redis Collection object to DotNet Redis Connection object |
- |
useInsertLink | Between the caller .NET Class / Method objects and Dotnet Redis Collection objects | StringSet StringSetAsync Add GeoAdd HashSet SetCombineAndStore AddItemToList AddItemToSet AddRangeToList AddRangeToSet CreateHashSet PushItemToList GetSetCount SetAsync |
useDeleteLink | Between the caller .NET Class / Method objects and Dotnet Redis Collection objects | KeyDelete Remove RemoveAll KeyDump RemoveItemFromSet RemoveItemFromList PopItemFromList RemoveAsync |
useSelectLink |
Between the caller .NET Class / Method objects and Dotnet Redis Collection objects | StringGet StringGetAsync GeoRadius GeoRadiusAsync HashGetAllAsync HashGetAll Sort HashScan SetScan Get GetHashCount GetHashKeys GetListCount GetAsync GetAndRefresh GetAndRefreshAsync |
useUpdateLink | Between the caller .NET Class / Method objects and Dotnet Redis Collection objects | StringIncrement StringIncrementAsync IncrementValueInHash |
What results can you expect?
Some example scenarios are shown below:
Redis Connections and Collections
public class TestRedis
{
// Configure Redis cache options
RedisCacheOptions cacheOptions = new RedisCacheOptions("localhost");
// Create a Redis cache instance
public RedisCache cache = new RedisCache(cacheOptions);
// Generate a cache key
var cacheKey = "Company";
public void deleteCompany()
{
// Remove the cached item
cache.Remove(cacheKey);
}
}
Insert Operation
public void insertCompany()
{
// Store a value in the cache
DistributedCacheEntryOptions options = new DistributedCacheEntryOptions();
byte byteArray = Encoding.UTF8.GetBytes("1, TATA, IND");
cache.Set(cacheKey, byteArray, options);
}
Select Operation
public void selectCompany()
{
// Retrieve the value from the cache
var cachedValue = cache.Get(cacheKey);
}
Update Operation
// Generate a cache key
var cacheKey = "myCounter";
public void update_()
{
// Retrieve the value from the cache
newValue = redisDb.StringIncrement(cacheKey);
}
Delete Operation
public void deleteCompany()
{
// Remove the cached item
cache.Remove(cacheKey);
}
Known Limitations
- Cases in which the name is not resolved, Unknown connection/collection object will get created