コード例 #1
0
        /// <summary>
        /// 清理活动站的Redis缓存
        /// </summary>
        /// <param name="cacheName"></param>
        /// <param name="cacheKey"></param>
        /// <returns></returns>
        public async Task <OperationResult <bool> > RemoveRedisCacheKeyAsync(string cacheName, string cacheKey, string prefixKey = null)
        {
            var realCacheKey = cacheKey;

            using (var client = CacheHelper.CreateCacheClient(cacheName))
            {
                if (!string.IsNullOrEmpty(prefixKey))
                {
                    var result = GlobalConstant.GetCacheKeyPrefixWithCache(prefixKey, cacheName);
                    if (result != null)
                    {
                        var timeSpan = result?.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).ToList().LastOrDefault();
                        if (!string.IsNullOrEmpty(timeSpan))
                        {
                            realCacheKey = GlobalConstant.ActivityDeafultCachPrefixValue
                                           .Replace("{cacheKey}", cacheKey)
                                           .Replace("{timespansecond}", timeSpan);
                        }
                    }
                }
                var isExists = client.Exists(realCacheKey);
                if (!string.IsNullOrEmpty(isExists.RealKey))
                {
                    var result = await client.RemoveAsync(realCacheKey);

                    return(OperationResult.FromResult <bool>(result.Success));
                }
            }
            return(OperationResult.FromResult(true));
        }
コード例 #2
0
ファイル: GlobalCode.cs プロジェクト: xmaxmex/Phalanger
            public GlobalConstantDeclCompiler(GlobalConstantDecl /*!*/ node)
            {
                QualifiedName qn = (node.Namespace != null)
                            ? new QualifiedName(new Name(node.Name.Value), node.Namespace.QualifiedName)
                            : new QualifiedName(new Name(node.Name.Value));

                constant = new GlobalConstant(qn, PhpMemberAttributes.Public, (CompilationSourceUnit)node.SourceUnit, node.IsConditional, node.Scope, node.Span);
                constant.SetNode(node);
            }
コード例 #3
0
ファイル: GlobalCode.cs プロジェクト: jiahao42/weverca
        public GlobalConstantDecl(SourceUnit /*!*/ sourceUnit, Position position, bool isConditional, Scope scope,
                                  string /*!*/ name, NamespaceDecl ns, Expression /*!*/ initializer)
            : base(position, name, initializer)
        {
            this.ns = ns;

            QualifiedName qn = (ns != null) ? new QualifiedName(new Name(name), ns.QualifiedName) : new QualifiedName(new Name(name));

            constant = new GlobalConstant(qn, PhpMemberAttributes.Public, sourceUnit, isConditional, scope, position);

            constant.SetNode(this);
        }
コード例 #4
0
        public async Task <OperationResult <bool> > RefreshRedisCachePrefixForCommonAsync(RefreshCachePrefixRequest request)
        {
            using (var client = CacheHelper.CreateCacheClient(request.ClientName))
            {
                var result = await client.SetAsync(request.Prefix, GlobalConstant.GenerateKeyPrefix(request.Prefix), request.Expiration);

                if (!result.Success)
                {
                    Logger.Warn($"更新Redis缓存失败,prefix==>{request.Prefix}", result.Exception);
                }
                return(OperationResult.FromResult(result.Success));
            }
        }