Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to add item because it exists after clear region #298

Open
rider11-dev opened this issue Jan 15, 2020 · 0 comments
Open

Failed to add item because it exists after clear region #298

rider11-dev opened this issue Jan 15, 2020 · 0 comments

Comments

@rider11-dev
Copy link

I'm using cache both in memory and redis,and I'm trying to reload cache using the following steps:
1.clear region(which is already loaded from app start);
2.add my new cache data;
It works in most cases,but I got a strange thing for "Failed to add item because it exists" sometimes ,
logs are as below:
2020-01-13 16:12:40.2798|TRACE|service:|CacheManager.Core.BaseCacheManager|Clear region: SysRegion.||traceid:|requestid:|GoldDustSyscfgCacheLoader.Load => BaseCacheManager1.ClearRegion => MicrosoftLoggerAdapter.Log
2020-01-13 16:12:40.2798|TRACE|service:|CacheManager.Core.BaseCacheManager|Clear region: SysRegion in handle innerMemoryCache.||traceid:|requestid:|GoldDustSyscfgCacheLoader.Load => BaseCacheManager1.ClearRegion => MicrosoftLoggerAdapter.Log 2020-01-13 16:12:40.2798|TRACE|service:|CacheManager.Core.BaseCacheManager|**Clear region: SysRegion in handle redisCache**.||traceid:|requestid:|GoldDustSyscfgCacheLoader.Load => BaseCacheManager1.ClearRegion => MicrosoftLoggerAdapter.Log
2020-01-13 16:12:40.2849|TRACE|service:|CacheManager.Core.BaseCacheManager|Clear region: SysRegion: notifies backplane [clear region].||traceid:|requestid:|GoldDustSyscfgCacheLoader.Load => BaseCacheManager1.ClearRegion => MicrosoftLoggerAdapter.Log 2020-01-13 16:12:40.2908|TRACE|service:|CacheManager.Core.BaseCacheManager|Add ['SysRegion:c|包装方式_n|1', exp:Default 00:00:00, lastAccess:2020-01-13 08:12:40.289] started.||traceid:|requestid:|CacheManagerHelper.Add => BaseCacheManager1.AddInternal => MicrosoftLoggerAdapter.Log
2020-01-13 16:12:40.2930|DEBUG|service:|CacheManager.Redis.RedisCacheHandle|DB 3 | Failed to add item ['SysRegion:c|包装方式_n|1', exp:Absolute 7.00:00:00, lastAccess:2020-01-13 08:12:40.289] because it exists.||traceid:|requestid:|RetryHelper.Retry => RedisCacheHandle1.Set => MicrosoftLoggerAdapter.Log 2020-01-13 16:12:40.2941|TRACE|service:|CacheManager.Core.BaseCacheManager|Evict [SysRegion:c|包装方式_n|1] from other handles excluding handle '1'.||traceid:|requestid:|BaseCacheManager1.AddInternal => BaseCacheManager1.EvictFromOtherHandles => MicrosoftLoggerAdapter.Log 2020-01-13 16:12:40.2941|DEBUG|service:|CacheManager.Core.BaseCacheManager|Evicting 'SysRegion:c|包装方式_n|1' from handle 'innerMemoryCache'.||traceid:|requestid:|BaseCacheManager1.EvictFromOtherHandles => BaseCacheManager1.EvictFromHandle => MicrosoftLoggerAdapter.Log 2020-01-13 16:12:40.2941|TRACE|service:|CacheManager.Core.BaseCacheManager|Add ['SysRegion:c|包装方式_n|2', exp:Default 00:00:00, lastAccess:2020-01-13 08:12:40.294] started.||traceid:|requestid:|CacheManagerHelper.Add => BaseCacheManager1.AddInternal => MicrosoftLoggerAdapter.Log
2020-01-13 16:12:40.2954|DEBUG|service:|CacheManager.Redis.RedisCacheBackplane|Backplane is sending 1 messages (0 skipped).||traceid:|requestid:|ExecutionContext.RunInternal => <b__0>d.MoveNext => MicrosoftLoggerAdapter.Log
2020-01-13 16:12:40.2966|DEBUG|service:|CacheManager.Redis.RedisCacheHandle|DB 3 | Failed to add item ['SysRegion:c|包装方式_n|2', exp:Absolute 7.00:00:00, lastAccess:2020-01-13 08:12:40.294] because it exists.||traceid:|requestid:|RetryHelper.Retry => RedisCacheHandle1.Set => MicrosoftLoggerAdapter.Log
I'm using aspnetcore2.1 with cachemanager 1.1.2.
This is my config code:
`Manager = CacheFactory.Build("enjoyDefaultCache", options =>
{
options.WithMicrosoftLogging(loggerFactory)//集成log
.WithUpdateMode(CacheUpdateMode.Up)//指定与上层缓存进行数据同步
.WithMicrosoftMemoryCacheHandle("innerMemoryCache")//一级缓存:内存
.WithExpiration(ExpirationMode.Absolute, TimeSpan.FromHours(2))//2小时过期
.EnableStatistics() //启用统计
//.EnablePerformanceCounters()
.And
.WithRedisConfiguration(CONFIG_KEY_REDIS, config =>
{
var rds = config.WithAllowAdmin()
.WithDatabase(3)
.WithEndpoint(endPoint.Address.ToString(), endPoint.Port);

                           if (!string.IsNullOrWhiteSpace(redisConfigOptions.Password))
                           {
                               rds.WithPassword(redisConfigOptions.Password);
                           }
                       })
                       //.WithMaxRetries(100)
                       //.WithRetryTimeout(50)
                       .WithJsonSerializer()//添加序列化组件,否则初始化rediscachehandle失败
                       .WithRedisBackplane(CONFIG_KEY_REDIS)//使用redis作为基准缓存
                       .WithRedisCacheHandle(CONFIG_KEY_REDIS, true)//二级缓存:声明redis缓存层,并指定为基准缓存
                       .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromDays(7))//一周过期
                       .EnableStatistics() //启用统计
                                           //.EnablePerformanceCounters()
                       ;
            });
        }`

So please give some help,thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant