/// <summary> /// Retrieves a cached object or loads the object if it does not exist in cache. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="cache"></param> /// <param name="cacheKey"></param> /// <param name="load"></param> /// <param name="insert"></param> /// <param name="regionName"></param> /// <returns></returns> public virtual T Get <T>( ObjectCache cache, string cacheKey, Func <ObjectCache, T> load, Action <ObjectCache, T> insert, string regionName = null) { return(LockManager.Get( cacheKey, // try to load from cache key => this.GetCacheItemValue(cache, key.ToLower(), regionName), key => { // load object from the service var obj = load(cache); if (insert != null) { // insert object into cache insert(cache, obj); } return obj; })); }