Exemple #1
0
        public static int GetCount(
            string ticket, GetItemDelegateCount functor, Cache cache, TimeSpan ts,
            string cacheticket)
        {
            if (cache == null)
            {
                return(functor(ticket));
            }
            string key   = GetCacheKey(functor.Method.Name, cacheticket);
            int    count = 0;

            if (!TryGet(cache, key, out count))
            {
                count = functor(ticket);
                Insert(cache, key, count, ts);
            }
            return((int)count);
        }
Exemple #2
0
        public static int GetCount <TypeArg1, TypeArg2, TypeArg3>(
            string ticket, TypeArg1 arg1, TypeArg2 arg2, TypeArg3 arg3,
            GetItemDelegateCount <TypeArg1, TypeArg2, TypeArg3> functor, Cache cache, TimeSpan ts,
            string cacheticket)
        {
            if (cache == null)
            {
                return(functor(ticket, arg1, arg2, arg3));
            }
            object[] args  = { arg1, arg2, arg3 };
            string   key   = GetCacheKey(functor.Method.Name, args, cacheticket);
            int      count = 0;

            if (!TryGet(cache, key, out count))
            {
                count = functor(ticket, arg1, arg2, arg3);
                Insert(cache, key, count, ts);
            }
            return((int)count);
        }