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

CAST supports Memcached via its NoSQL for .NET extension. Details about the support provided for .NET source code is discussed below.

Supported Client Libraries

Supported Operations

OperationMethods Supported
Select
  • Get
  • GetAsync
Insert
  • Store
  • StoreAsync
Delete
  • Remove
  • RemoveAsync
Update
  • Increment
  • Decrement
  • Append
  • Prepend

Objects

IconDescription

DotNet Memcached Connection


DotNet Memcached Data

DotNet Unknown Memcached Connection

DotNet Unknown Memcached Data

Links

Links are created for transaction and function point needs:

Link typeSource and destination of link Methods supported
parentLink

Between Memcached connection object and Memcached Data object.


useLink

Between the caller .Net method object and Memcached Data object.





useSelectLink
  • Get
  • GetAsync
useInsertLink
  • Store
  • StoreAsync

useDeleteLink

  • Remove
  • RemoveAsync
useUpdateLink
  • Increment
  • Decrement
  • Append
  • Prepend

What results can you expect?

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

Memcached Connection

  • In the Memcached class file, when we add the server information by parsing the ipaddress and provide the port Number. Below is a sample source code with its result in Enlighten 
public MemcacedCache()
      {
         _logger = new Logger();
         var config = new MemcachedClientConfiguration();
         config.Servers.Add(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 11211));
         config.Protocol = MemcachedProtocol.Binary;
         
         _cache = new MemcachedClient(null, config);
      }

  • In the Memcached class file, when we pass the server information as a parameter. Below is a sample source code with its result in Enlighten :
namespace MemcachedTryout
{
   internal class MemcacedCache : ICache
   {  const string MEMCACHE_HOST = "127.0.0.1";
      const int MEMCACHE_PORT = 14551;
      public MemcacedCache()
      {
        _logger = new Logger();
         var config = new MemcachedClientConfiguration();
         config.Servers.Add(GetIPEndPointFromHostName(MEMCACHE_HOST, MEMCACHE_PORT));
         _cache = new MemcachedClient(null, config);
      }
  ---
}


  • Unknown Connection Object: In the Memcached class file, when we pass the server information as a parameter and if passed parameter is unresolved it will create Unknown Connection Object. Below is a sample source code with its result in Enlighten:
namespace MemcachedTryout
{
   internal class MemcacedCache : ICache
   {
      private readonly MemcachedClient _cache;
      private readonly ILogger _logger;

      public MemcacedCache()
      {
         _logger = new Logger();
         var config = new MemcachedClientConfiguration();
         config.Servers.Add(GetIPEndPointFromHostName(MEMCACHE_HOST, MEMCACHE_PORT));     
         _cache = new MemcachedClient(null, config);
      }
 ----
}

  • If the server information is provided in xml file. Below is a sample source code with its result in Enlighten :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="enyim.com">
      <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
    </sectionGroup>
  </configSections>

  <enyim.com>
    <memcached protocol="Binary">
      <servers>
         <!--put your own server(s) here-->
        <add address="127.0.0.1" port="11211" />
      </servers>
    </memcached>
  </enyim.com>
</configuration>


  • Support of WazMemcached Library. Below is a sample source code with its result in Enlighten:
public string MemcachedRoleName { get; set; }
public string EndpointName { get; set; }
private MemcachedClient Client
{
   get { return _client ?? (_client = WindowsAzureMemcachedHelpers.CreateDefaultClient(MemcachedRoleName, EndpointName)); }
}

Insert Operation for various Memcached Data

public async Task<bool> Addsync<T>(string key, T value)
      {
         _logger.Debug("Adding item to cache with key {0}", key);
         return await _cache.StoreAsync(StoreMode.Set, "Hello", value, TimeSpan.FromDays(90));
      }

Select Operation for various Memcached Data

public async Task<T> GetAsync<T>(string key)
      {
         var cacheItem = await _cache.GetAsync<T>(key);
      }

Delete Operation for various Memcached Data

public async Task<bool> Removesync(string key)
      {
         _logger.Debug("Removing item from cache with key {0}", key);

         return await _cache.RemoveAsync(key);
      }

Update Operation for various Memcached Data

public async Task<bool> Updatesync<T>(string key, T value)
      {
         _cache.Increment("num1", 1, 10);
         _cache.Decrement("num2", 1, 20);     
      }

Evolution

  • Previously, only  files consisting of relevant Memcached imports were processed further for analysing.
  • Support has been evolved to process a  file when it does not contain Memcached import but makes use of its methods (APIs). Assumption here is  file is using same namespace as used in the file containing Memcached imports.

Limitations

  • Connection and data names are resolved as known Connection and data only in the following situations:
    • Name is hardcoded
    • Name is defined in the variable in the local method
    • Name is defined as C# field

Future development

  • Resolving the Connection/data name when passed as arguments in methods.
  • No labels