abp icon indicating copy to clipboard operation
abp copied to clipboard

Investigate if redis cache supports local caching & synchronization

Open hikalkan opened this issue 6 years ago • 6 comments

For the values rarely changed but frequently read, it would be better to keep a copy in the memory to reduce cache read time when we use the redis cache.

I suppose redis has such a feature. We should investigate it and look for how to adapt to the framework.

hikalkan avatar May 07 '20 15:05 hikalkan

Hi hikalkan, Would like to understand the Problem better let me put-forth the below and see how this one is different from our requirement. Say for example, For model class Customer we have 10 fields

  • 5 Columns - Read frequently and rarely update
  • 5 Columns - Update frequently

Read Frequently columns at design time can be specified with [CacheUntilNextUpdate] attribute.

Code First Approach should generate an equivalent Migration script based on this attribute specified as

  • CustomerFrequentReadTable ( Column6, Column7, Column8,Column9,Column10 )
    • This data will be cached.
  • CustomerFrequentUpdateTable ( Column1, Column2, Column3,Column4,Column5 )
    • This data is not cached `public class Customer { public int ID { get; set; }

      public string Column1 { get; set; } ............... public string Column5 { get; set; }

      [CacheUntilNextUpdate] public int Column6 { get; set; } ............... [CacheUntilNextUpdate] public bool Column10 { get; set; } }` LINQ Query should be like

      customer.column1 ( will be read from DB) customer.Column6 ( will be read from Cache)

So instead of using the Redis cache can this be not done by a Vertical Partition of Table at Design time and improve the overall query execution time?

MohanaRanjan avatar May 11 '20 12:05 MohanaRanjan

Thank @MohanaRanjan for joining to the discussion. However, my case is like caching application settings or user permissions those are not frequently changing but frequently read.

Partically caching an entity seems interesting but I don't interest in it now :)

hikalkan avatar May 11 '20 21:05 hikalkan

@hikalkan A little off-topic question. Is Redis required or optional for IdentityServer (and if it is optional - can I comment-out Redis-related configuration in Startup.cs)?

leonkosak avatar Jun 05 '20 11:06 leonkosak

Is Redis required or optional for IdentityServer

You can remove, then it will use in-memory cache. But in this case, IDS4 and your API will have separate caches don't know each other and you (natually) have problems about data consistensy.

If you develop distributed system, you need to use a distributed cache.

If you don't use a distributed cache, then create a monolith application that includes IDS, API, Web together, which is the default startup template.

hikalkan avatar Jun 14 '20 10:06 hikalkan

I suppose Redis supports it: https://redis.io/topics/client-side-caching However, StackExchange.Redis NuGet package doesn't support it: https://github.com/StackExchange/StackExchange.Redis/issues/1461

So, we may consider to implement this ourselves.

hikalkan avatar Mar 15 '21 18:03 hikalkan

Already covered by https://github.com/abpframework/abp/issues/13951

hikalkan avatar Sep 03 '23 17:09 hikalkan