I am using CacheManager.Net, I am trying to add a CacheItem to a ICacheManager object, but I get the following exception "Object reference not set to an instance of an object.".
Following is some code snippet:
public class ReaderController{
private ICacheManager<object> tagReadEventsCache;
public ReaderController()
{
tagReadEventsCache = CacheFactory.Build("tagReadEventsCache", settings => settings
.WithUpdateMode(CacheUpdateMode.Up)
.WithSystemRuntimeCacheHandle("Zones")
.WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMilliseconds(1000)));
tagReadEventsCache.OnAdd += TagReadEventsCache_OnAdd;
}
private void TagReadEventsCache_OnAdd(object sender, CacheManager.Core.Internal.CacheActionEventArgs e)
{
generalLog.Debug(e.Key + " - " + e.Region + " - " + e.GetType().ToString());
}
public void AddTagReadEventCache(List<TagRead> tagReadEvent)
{
foreach (TagRead tag in tagReadEvent)
{
try
{
var item = new CacheItem<object>(tag.Epc, tag, ExpirationMode.Sliding, TimeSpan.FromMilliseconds(10000));
//tagReadEventsCache.Put(item);
tagReadEventsCache.Add(item);
}
catch (Exception ex)
{
generalLog.Error("Excepcion tag " + tag.ReaderHostName, ex);
}
}
}
....
}
So when the AddTagReadEventCache method is called it generates the exception when it tries to add an Cacheitem, also I did try the Put method and happens the same. I know it should be some small thing I am missing somewhere, But I am stock, I really appreciate someone help.
Thanks