예제 #1
0
        private static InkeyResult <string> GetMemcachedResult(string actionType, string sType, string vType, string cacheResult, FormatObjcet formart, List <string> pValueList)
        {
            InkeyResult <string> result = new InkeyResult <string>();
            var cacheManager            = new MemcachedManager(new CacheManagerActionCacheKeyFormat());
            var flag = false;

            switch (actionType)
            {
            case "View":
                object value = string.Empty;
                flag = cacheManager.RawIsSet(formart.Key, out value, pValueList.ToArray());
                if (!flag)
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;
                    result.Desc = "未设置缓存值";
                    return(result);
                }
                else
                {
                    result.Data = value is string?(string)value : value.ToJsonString();
                }
                break;

            case "Update":
                if (cacheManager.RawIsSet(formart.Key, out value, pValueList.ToArray()) && !(value is string))
                {
                    value = JsonConvert.DeserializeObject(cacheResult, value.GetType());
                    flag  = cacheManager.RawSet(formart.Key, value, pValueList.ToArray());
                }
                else
                {
                    flag = cacheManager.RawSet(formart.Key, cacheResult, pValueList.ToArray());
                }
                if (!flag)
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;
                    result.Desc = "请输入JSON";
                    return(result);
                }
                else
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;    //前端需要弹出提示,所有设置这个值
                    result.Desc = "更新成功";
                }
                break;

            case "Delete":
                flag = cacheManager.Remove(formart.Key, pValueList.ToArray());
                if (!flag)
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;
                    result.Desc = "缓存移除失败";
                    return(result);
                }
                break;
            }
            return(result);
        }
예제 #2
0
 public SerialNumberService(string key, SerialNumberCreateType createType, IDataAccessFactory dataAccessFactory)
 {
     this._key               = key;
     this._createType        = createType;
     this._dataAccessFactory = dataAccessFactory;
     this._serialNumberDao   = dataAccessFactory.GetDataAccess <ISerialNumberDao>();
     this._config            = _configDict.GetOrAdd(this._key, (k) => this._serialNumberDao.GetSerialNumberConfigByKey(this._key));
     this._cacheManager      = new MemcachedManager(IKCacheFactory.CacheKeyFormat);
 }
        public void TestMethod1()
        {
            MemcachedManager m = new MemcachedManager();
            var c = m.Get <string>("api_keyTest");

            if (string.IsNullOrEmpty(c))
            {
                m.Set("api_keyTest", "test");
            }
            c = m.Get <string>("api_keyTest");
        }
예제 #4
0
        public void Initialize()
        {
            cacheManager = new MemcachedManager(AuthServiceCacheFactory.CacheKeyFormat);
            var authService = new AuthAppService();

            this._appCode = AppInfo.AppCode;
            if (string.IsNullOrEmpty(this._appCode))
            {
                throw new AuthException("应用标识未配置");
            }
            var appRootFuncList = authService.GetAuthAppRootFunctionList(this._appCode);

            foreach (var item in appRootFuncList)
            {
                var allFuncList = authService.GetAllAuthFunctionList(this._appCode, item.FuncCode);
                allFuncList.Add(item);
                _rootFuncs.AddOrUpdate(item.FuncCode, allFuncList.ToDictionary(s => s.FuncCode), (key, func) => func);
            }

            if (SubscriptionManager.IsSubscriberContextInitialize)
            {
                SubscriptionManager.Subscriber.RegisterConsumerType(typeof(IkAuthorization));
            }
        }
예제 #5
0
 public WhalinMemcachedAdapter()
     : this(MemcachedManager.CreateClient())
 {
 }
예제 #6
0
 static MemcachedManagerTests()
 {
     _client = new MemcachedManager("enyim.com/memcached");
 }