We want to use the extention methods used in this package : KeyDeleteWithPrefix() and KeyCount()
We followed the ABP's Caching Documention and aded Abp.RedisCache in Web.Core's Project Module.
We added this in DependsOn Annotation and enable redis by using below
//See app.config for Redis configuration and connection string
Configuration.Caching.UseRedis(options =>
{
options.ConnectionString = _appConfiguration["Abp:RedisCache:ConnectionString"];
options.DatabaseId = _appConfiguration.GetValue<int>("Abp:RedisCache:DatabaseId");
});
Then I created a helper class for Redis Caching and injected
public class RedisCacheHelper : IRedisCacheHelper
{
private readonly IConfigurationRoot _appConfiguration;
private readonly AbpRedisCacheManager _cacheManger;
public RedisCacheHelper(IHostingEnvironment env, AbpRedisCacheManager cacheManger)
{
_appConfiguration = env.GetAppConfiguration();
_cacheManger = cacheManger;
}
}
Earlier we were using IDistributedCache in place of AbpRedisCacheManager. After doing these steps we are not able to find any methods to add or get value with particular key in Redis cache like we had in IDistributedCache. We also not able to get redis database (IDatabase) which contains the methods KeyDeleteWithPrefix() and KeyCount()
How can we implement this ?
6 Answer(s)
-
1
After doing these steps we are not able to find any methods to add or get value with particular key in Redis cache like we had in IDistributedCache.
Can you explain it in detail?
We also not able to get redis database (IDatabase) which contains the methods KeyDeleteWithPrefix() and KeyCount()
IDatabase database = redisCacheDatabaseProvider.GetDatabase(); database.KeyDeleteWithPrefix() database.KeyCount()
https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.RedisCache/Runtime/Caching/Redis/AbpRedisCache.cs#L29
-
0
My requirement is to perform the following operations :
- Get value from cache
- Set value in cache
- Delete by Prefix
- Get count by Prefix
I am implementing a helper class which fetches the AbsoluteExpiration and SlidingExpiration from the appsetting.json files.
I see there are Get() and Set() methods inside AbpRedisCache class but I also need access to IDatabase to fire database.KeyDeleteWithPrefix()
Is it AbpRedisCache or IAbpRedisCacheDatabaseProvider
-
0
@sumitshah
You can inject
IAbpRedisCacheDatabaseProvider
and get the database usingredisCacheDatabaseProvider.GetDatabase()
. Then, you can useKeyDeleteWithPrefix
method. -
0
As RedisDatabaseExtensions class was internal we had to copy its implementations to our helper class. Doing so we were able to get "count by key prefix".
However, after migrating from .Net IDistributedCache to Abp.RedisCache package we observed that values are now being stored as string type in Redis instead of hash type.
As hash type is much safer we want to contine using it.
Is there any way to store the values in Hash format.
-
0
hi @sumitshah
The current design is to store the value as a string. You can use the redis API to Implement your own needs.
-
0
This issue is closed because of no recent activity. Please create a new issue if you are still having this problem.