Description
Hello Alastair,
I am currently using the 0.7.1.44 version in my .net application. i added to some logging inside my Db call method and i noticed that Db calls are being made rather frequently. I currently have a sliding expiration policy for 7 days, but the method is called multiple times same day.
here is a portion of today's logs
2020-01-16 00:07:41.7333 INFO Calling ActivityFeedDB: 5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6:POSTS
2020-01-16 00:22:51.7508 INFO Calling ActivityFeedDB: 5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6:POSTS
2020-01-16 00:34:34.8084 INFO Calling ActivityFeedDB: 5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6:POSTS
2020-01-16 01:30:59.2897 INFO Calling ActivityFeedDB: 5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6:POSTS
2020-01-16 03:31:42.4026 INFO 1/16/2020 3:31:42 AM Removing Cache: CachedActivityFeed:5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6-POSTS CacheSpecificEviction
2020-01-16 11:27:02.1429 INFO Calling ActivityFeedDB: 5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6:POSTS
2020-01-16 14:37:11.0202 INFO Calling ActivityFeedDB: 5a10c9e6-eb2c-41f0-9fc8-20c0fe6643f6:POSTS
these are snippets of my code:
private static readonly CacheItemPolicy policy = new CacheItemPolicy()
{
Priority = CacheItemPriority.Default,
RemovedCallback = new CacheEntryRemovedCallback(Factory.OnCacheExpired),
SlidingExpiration = new TimeSpan(7, 0, 0, 0, 0)
};
public static CachedActivityFeed GetItem(Guid? activityid, int? id, Site_Activities.Activities type)
{
try
{
return Factory.GetOrAdd(GetCacheID(activityid, id, type), () => Construct(activityid, id, type), policy);
}
catch (Exception)
{
return null;
}
}
public static T GetOrAdd<T>(string key, Func<T> func, CacheItemPolicy cacheItemPolicy)
{
var result = TempCache.cache.GetOrAdd(key, func, cacheItemPolicy);
return result;
}
public static IAppCache cache = new CachingService();
Am i doing something wrong implementation wise? or is this a know bug thats fixed with an upgrade?
Great Lib!