Page tree
Skip to end of metadata
Go to start of metadata

CAST supports Redis via its NoSQL for .NET extension. Details about how this support is provided for .NET source code is discussed below.

Supported Client Libraries

Supported Operations

OperationMethods Supported
Insert
  • StackExchange.Redis.IDatabase.StringSet
  • StackExchange.Redis.IDatabaseAsync.StringSetAsync
  • StackExchange.Redis.IDatabase.Add
  • StackExchange.Redis.IDatabase.GeoAdd'
  • StackExchange.Redis.IDatabase.HashSet
  • StackExchange.Redis.IDatabase.SetCombineAndStore
  • ServiceStack.Redis.RedisClient.AddItemToList
  • ServiceStack.Redis.RedisClient.AddItemToSet
  • ServiceStack.Redis.RedisClient.AddRangeToList
  • ServiceStack.Redis.RedisClient.AddRangeToSet
  • ServiceStack.Redis.RedisClient.CreateHashSet
  • ServiceStack.Redis.RedisClient.PushItemToList
Update
  • StackExchange.Redis.IDatabase.StringIncrement
  • StackExchange.Redis.IDatabaseAsync.StringIncrementAsync
  • StackExchange.Redis.IDatabase.KeyMigrate
  • ServiceStack.Redis.RedisClient.IncrementValueInHash
Select
  • 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
  • ServiceStack.Redis.RedisClient.GetHashCount
  • ServiceStack.Redis.RedisClient.GetHashKeys
  • ServiceStack.Redis.RedisClient.GetListCount
  • ServiceStack.Redis.RedisClient.GetSetCount
Delete 
  • StackExchange.Redis.IDatabase.KeyDelete
  • StackExchange.Redis.IDatabase.Remove
  • StackExchange.Redis.IDatabase.RemoveAll
  • StackExchange.Redis.IDatabase.KeyDump
  • ServiceStack.Redis.RedisClient.RemoveItemFromSet
  • ServiceStack.Redis.RedisClient.RemoveItemFromList
  • ServiceStack.Redis.RedisClient.PopItemFromList

Objects

Icon Description

DotNet Redis Connection

DotNet Redis Collection

DotNet Unknown Redis Connection

 

DotNet Unknown Redis Collection 

Links are created for transaction and function point needs:

Link typeSource and destination of link Methods supported
belongsTo

From DotNet Redis Collection object to DotNet Redis Connection object


useInsertLinkBetween the caller .NET Class / Method objects and Dotnet Redis Collection objects


  • StringSet
  • StringSetAsync
  • Add
  • GeoAdd
  • HashSet
  • SetCombineAndStore
  • AddItemToList
  • AddItemToSet
  • AddRangeToList
  • AddRangeToSet
  • CreateHashSet
  • PushItemToList
  • GetSetCount
 useDeleteLink
  • KeyDelete
  • Remove
  • RemoveAll
  • KeyDump
  • RemoveItemFromSet
  • RemoveItemFromList
  • PopItemFromList

useSelectLink

  • StringGet
  • StringGetAsync
  • GeoRadius
  • GeoRadiusAsync
  • HashGetAllAsync
  • HashGetAll
  • Sort
  • HashScan
  • SetScan
  • Get
  • GetHashCount
  • GetHashKeys
  • GetListCount
useUpdateLink
  • StringIncrement
  • StringIncrementAsync
  • IncrementValueInHash

What results can you expect?

Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.


Connections:

 Connection
public Issue898()
        {
            mux = ConnectionMultiplexer.Connect("127.0.0.1:6379");
            db = mux.GetDatabase();
        }

Insert_operation

 Insert operation
public async Task LoadAsync()
        {
            for (int i = 0; i < max; ++i)
            {
                await db.StringSetAsync(i.ToString(), i).ConfigureAwait(false);
            }
        }

SeviceStack
public void AdditemlistById(string id)
        {
           
            if (this.Pipeline != null)
                GetRegisteredTypeIdsWithinPipeline(typeIdsSetKey).Remove(id);
            else
                this.AddItemToList("list_01", id);

Select_operation

 Select Operation
[Benchmark(OperationsPerInvoke = max)]
        public async Task SampleAsync()
        {
            var rnd = new Random();

            for (int i = 0; i < max; ++i)
            {
                var r = rnd.Next(0, max - 1);

                var rv = await db.StringGetAsync(r.ToString()).ConfigureAwait(false);
                if (rv != r)
                {
                    throw new Exception($"Unexpected {rv}, expected {r}");
                }
            }
        }

Update_operation

 Update operation
public async Task<int> ExecuteIncrByAsync()
        {
            var rand = new Random(12345);

            db.KeyDelete(IncrByKey, CommandFlags.FireAndForget);
            int expected = 0;
            for (int i = 0; i < COUNT; i++)
            {
                int x = rand.Next(50);
                expected += x;
                await db.StringIncrementAsync(IncrByKey, x, CommandFlags.FireAndForget).ConfigureAwait(false);
            }
            int actual = (int)await db.StringGetAsync(IncrByKey).ConfigureAwait(false);
            if (actual != expected) throw new InvalidOperationException($"expected: {expected}, actual: {actual}");
            return actual;
        }

Delete_operation

 Delete operation
public int ExecuteIncrBy()
        {
            var rand = new Random(12345);

            db.KeyDelete(IncrByKey, CommandFlags.FireAndForget);
            int expected = 0;
            for (int i = 0; i < COUNT; i++)
            {
                int x = rand.Next(50);
                expected += x;
                db.StringIncrement(IncrByKey, x, CommandFlags.FireAndForget);
            }
            int actual = (int)db.StringGet(IncrByKey);
            if (actual != expected) throw new InvalidOperationException($"expected: {expected}, actual: {actual}");
            return actual;
        }

public void RemoveitemlistById(string id)
        {
            var typeIdsSetKey = "List_1";
            if (this.Pipeline != null)
                GetRegisteredTypeIdsWithinPipeline(typeIdsSetKey).Remove(id);
            else
                this.RemoveItemFromList("list_01", id);
        }

Evolution

  • Support for ServiceStack.redis library
  • Resolution for Connection, Collection objects and crud links has increased

Limitations

  • When the name is not resolved, unknown connection/collection object gets created
  • Support List, Set and Hash operation for Servicestack.Rediscollection object gets created

Future development

  •  Full support for service stack.Redis Native client






  • No labels