This commit is contained in:
2022-12-16 06:01:23 +00:00
parent 26c2ae5cc9
commit effd96143f
310 changed files with 48715 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace Sockeye.Util
{
//Object cache - used by biz objects during get report data to temporarily cache values from database for single request
//saves db calls and formatting
internal class ObjectCache
{
private Dictionary<string, object> _cache = new Dictionary<string, object>();
// internal ObjectCache()
// {
// System.Diagnostics.Debug.WriteLine("constructing objectcache");
// }
internal void Clear()
{
_cache.Clear();
}
internal void Add(object value, string key, long? id = 0)
{
_cache[$"{key}{id}"] = value;
// System.Diagnostics.Debug.WriteLine($"ADD {key}{id} - {value}");
}
internal object Get(string key, long? id = 0)
{
object value = null;
if (_cache.TryGetValue($"{key}{id}", out value))
{
//System.Diagnostics.Debug.WriteLine($"get cache hit {key}{id}");
return value;
}
else
{
//System.Diagnostics.Debug.WriteLine($"get cache miss {key}{id}");
return null;
}
}
internal bool Has(string key, long? id = 0)
{
return _cache.ContainsKey($"{key}{id}");
}
}//eoc
}//eons