...
Supported Operations
Operation | Methods Supported |
---|
Select |
Expand |
---|
title | Select Methods Supported |
---|
|
Expand |
---|
title | Select Methods For Enyim Library |
---|
| - Enyim.Caching.MemcachedClient.Get
- Enyim.Caching.MemcachedClient.GetAsync
- Enyim.Caching.MemcachedClient.ExecuteGet
|
Expand |
---|
title | Select Methods For CacheManager Library |
---|
| - CacheManager.Core.ICache.Get
- CacheManager.Core.ICache.Exists
- CacheManager.Core.ICache.Expire
|
Expand |
---|
title | Select Methods For LazyCache Library |
---|
| - LazyCache.AppCacheExtensions.GetOrAdd
- LazyCache.AppCacheExtensions.GetOrAddAsync
|
|
|
Insert |
Expand |
---|
title | Insert Methods Supported |
---|
|
Expand |
---|
title | Insert Methods For Enyim Library |
---|
| - Enyim.Caching.MemcachedClient.Store
- Enyim.Caching.MemcachedClient.StoreAsync
- Enyim.Caching.MemcachedClient.ExecuteStore
|
Expand |
---|
title | Insert Methods For Cachemanager |
---|
| - CacheManager.Core.ICacheManager.GetOrAdd
- CacheManager.Core.ICacheManager.TryGetOrAdd
|
Expand |
---|
title | Insert Methods For LazyCache |
---|
| - LazyCache.AppCacheExtensions.GetOrAdd
- LazyCache.AppCacheExtensions.GetOrAddAsync
- LazyCache.AppCacheExtensions.Add
|
|
|
Delete |
Expand |
---|
title | Delete Methods Supported |
---|
|
Expand |
---|
title | Delete Methods For Enyim Library |
---|
| - Enyim.Caching.MemcachedClient.Remove
- Enyim.Caching.MemcachedClient.RemoveAsync
- Enyim.Caching.MemcachedClient.ExecuteRemove
|
Expand |
---|
title | Delete Methods For Cachemanager |
---|
| - CacheManager.Core.ICache.Remove
|
Expand |
---|
title | Delete Methods For LazyCache |
---|
| - LazyCache.IAppCache.Remove
|
|
|
Update |
Expand |
---|
title | Update Methods Supported |
---|
|
Expand |
---|
title | Update Methods For Enyim |
---|
| - Enyim.Caching.MemcachedClient.Increment
- Enyim.Caching.MemcachedClient.IncrementAsync
- Enyim.Caching.MemcachedClient.ExecuteIncrement
- Enyim.Caching.MemcachedClient.Decrement
- Enyim.Caching.MemcachedClient.DecrementAsync
- Enyim.Caching.MemcachedClient.ExecuteDecrement
- Enyim.Caching.MemcachedClient.Append
- Enyim.Caching.MemcachedClient.AppendAsync
- Enyim.Caching.MemcachedClient.PrependAsync
- Enyim.Caching.MemcachedClient.ExecuteAppend
- Enyim.Caching.MemcachedClient.Prepend
- Enyim.Caching.MemcachedClient.ExecutePrepend
- Enyim.Caching.MemcachedClient.Replace
- Enyim.Caching.MemcachedClient.ReplaceAsync
|
Expand |
---|
title | Update Methods For Cachemanager |
---|
| - CacheManager.Core.ICache.Put
- CacheManager.Core.ICacheManager.Update
- CacheManager.Core.ICacheManager.TryUpdate
- CacheManager.Core.ICacheManager.AddOrUpdate
|
|
|
Objects
Icon | Description |
---|
| DotNet Memcached Connection |
| DotNet Memcached Data |
| DotNet Unknown Memcached Connection |
| DotNet Unknown Memcached Data |
...
Links are created for transaction and function point needs:
Link type | Source and destination of link | Methods supported |
---|
parentLinkBetween connection and Data .useLink
|
useSelectLink | Between the caller .Net method object and DotNet Memcached Data object |
.useSelectLink |
| |
useInsertLink | - Store
- StoreAsync
- ExecuteStore
|
useDeleteLink | - Remove
- RemoveAsync
- ExecuteRemove
|
useUpdateLink | - Increment
- IncrementAsync
- ExecuteIncrement
- Decrement
- DecrementAsync
- ExecuteDecrement
- Append
- AppendAsync
- ExecuteAppend
- Prepend
- PrependAsync
- ExecutePrepend
|
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
Expand |
---|
title | Memcached Client Configuration |
---|
|
- 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
|
...
Code Block |
---|
| 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);
} |
Image Modified
- 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 :
Code Block |
---|
| 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);
}
---
} |
Image Modified
|
...
- If the server information
|
...
- is provided in xml file. Below is a sample source code with its result in Enlighten :
namespace MemcachedTryout
{
internal class MemcacedCache : ICache
{ |
|
title | App.config code block |
---|
| <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
<sectionGroup name="enyim.com">
| private readonly MemcachedClient _cache;
<section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
</sectionGroup>
| privatereadonlyILogger _logger;</configSections>
<enyim.com>
| public MemcacedCache()<memcached protocol="Binary">
| {_logger = new Logger();
<!--put your own server(s) here-->
| var config = new MemcachedClientConfiguration();
<add address="127.0.0.1" port="11211" />
</servers>
</memcached>
</enyim.com>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout | config.Servers.Add(GetIPEndPointFromHostName(MEMCACHE_HOST, MEMCACHE_PORT)); type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>
<root>
| _cache new MemcachedClient(null, config);
"Debug" />
<appender-ref ref="ConsoleAppender" />
</root>
| }----
} |
Image Removed
...
</log4net>
</configuration> |
Image Added
|
Expand |
---|
title | Memcached 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
|
...
|
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="enyim.com"> |
---|
| namespace MemcachedTryout
{
internal class MemcacedCache : ICache
{
| <section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />private readonly MemcachedClient _cache;
| </sectionGroup></configSections>
<enyim.com><memcached protocol="Binary"><servers><!--put your own server(s) here-->_logger = new Logger();
var | <addaddress="127.0.0.1" port="11211" />
</servers>= new MemcachedClientConfiguration();
config.Servers.Add(GetIPEndPointFromHostName(MEMCACHE_HOST, MEMCACHE_PORT));
_cache = new MemcachedClient(null, config);
| </memcached></enyim.com>
</configuration> |
...
Image Added
|
Expand |
---|
title | Support of WazMemcached Library |
---|
|
...
|
- Below is a sample source code with its result in Enlighten:
Code Block |
---|
| public string MemcachedRoleName { get; set; }
public string EndpointName { get; set; }
private MemcachedClient Client
{
get { return _client ?? (_client = WindowsAzureMemcachedHelpers.CreateDefaultClient(MemcachedRoleName, EndpointName)); }
} |
Image Modified
|
CRUD Operations
...
Expand |
---|
|
Expand |
---|
title | Insert Operations For Enyim |
---|
|
Code Block |
---|
| public async Task<bool> Addsync<T>(string key, T value)
{
_logger.Debug("Adding item to cache with key {0}", key);
return await _cache. |
| StoreAsyncStore(StoreMode.Set, "Hello", value, TimeSpan.FromDays(90));
} |
Image Added
|
|
Image Removed
...
title | Insert Operations For Cachemanager |
---|
|
Code Block |
---|
| public ValuesController(ICacheManager<string> valuesCache, ICacheManager<int> intCache, ICacheManager<DateTime> dates)
{
_cache = valuesCache;
dates.Add("now", DateTime.UtcNow);
intCache.Add("count", 1);
} |
Image Added
|
|
Expand |
---|
|
Code Block |
---|
language | c#
Expand |
---|
title | Select Operations for Enyim |
---|
|
Code Block |
---|
public async Task<T> |
| GetAsync<T>Getsync<T>(string key)
{
var cacheItem = await _cache.Get<T>(Constants.num33);
if (cacheItem == null)
{
_logger.Debug("Cache miss with key {0}", key);
return default(T);
}
_ |
| cache.GetAsync<T>logger.Debug("Cache hit with key {0}", key);
return cacheItem;
}
|
Image Added
|
Expand |
---|
title | Select Operations for CacheManager |
---|
|
Code Block |
---|
public IActionResult Get(string key)
{
var value = _cache.GetCacheItem(key);
if (value == null)
{
return NotFound();
}
return Json(value.Value);
}
|
|
|
---|
Image Removed
Delete Operation for various Memcached Data
Image Added
|
Expand |
---|
title | Select Operations for LazyCache |
---|
|
Code Block |
---|
[HttpGet]
[Route("api/dbtime")]
public DbTimeEntity Get()
{
Func<DbTimeEntity> actionThatWeWantToCache = () => dbContext.GeDbTime();
var cachedDatabaseTime = cache.GetOrAdd(cacheKey, actionThatWeWantToCache);
return cachedDatabaseTime;
}
|
Image Added
|
|
Expand |
---|
|
Code Block |
---|
language | c#
Expand |
---|
title | Delete Operations for Enyim |
---|
|
Code Block |
---|
public async Task<bool> Removesync(string key)
{
_logger.Debug("Removing item from cache with key {0}", key); |
|
RemoveAsync |
---|
Image Removed
Update Operation for various Memcached Data
Image Added
|
Expand |
---|
title | Delete Operations for CacheManager |
---|
|
Code Block |
---|
public IActionResult Delete(string key)
{
if (_cache.Remove(key))
{
return Ok();
}
return NotFound();
}
|
Image Added
|
Expand |
---|
title | Delete Operations for LazyCache |
---|
|
Code Block |
---|
[HttpDelete]
[Route("api/dbtime")]
public IActionResult DeleteFromCache()
{
cache.Remove(cacheKey);
var friendlyMessage = new {Message = $"Item with key '{cacheKey}' removed from server in-memory cache"};
return Ok(friendlyMessage);
}
|
Image Added
|
|
Expand |
---|
|
Expand |
---|
title | Update Operations for Enyim |
---|
|
Code Block |
---|
public async Task<bool> Updatesync<T>(string key, T value)
{
|
| _cache.Increment("num1", 1, 10);
} |
Image Added
|
Expand |
---|
title | Update Operations CacheManager |
---|
|
Code Block |
---|
public IActionResult Put(string key, [FromBody]string value)
{
if (_cache. |
| Decrement"num2"120; => value) != null)
{
return Ok();
}
return NotFound();
} |
|
|
...
Image Added
|
|
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.Support provided for reading connection details from configuration files
- Added Support for all the CRUD operations of LazyCache and CacheManager Libraries
Limitations
- Limited resolution available. In case data is not resolved, it is reflected as unknown value