Esempio n. 1
0
        public void Add <T>(TKeyType Key, T Value)
        {
            lock (operateLock)
            {
                try
                {
                    CreateCachePath(Key);

                    //当前类型是基础类型或者是string
                    //var ct = typeof (T);
                    //if (ct.IsPrimitive || ct == typeof (string))
                    //{
                    //    File.WriteAllText(GetCacheName(Key), Value.ToString());
                    //}
                    //else
                    //{
                    File.WriteAllText(GetCacheName(Key), _isBinary ? Convert.ToBase64String(Value.SerializeBinary()) : Value.Serialize());
                    //}
                }
                catch (Exception ex)
                {
                    _log.Trace("异常:新增文件缓存:" + CacheName + ",key:" + Key);
                    _log.Error(ex);
                }
            }
        }