CustomTable_CachingIssue

Chandni Negi asked on June 23, 2025 09:31

My cache is not invalidating for customtable . SO I am refering this code public static IEnumerable< My_ViewModel > MethodName(List< IWhereCondition > conditions = null) { string cacheKey = "customtable.tablename.list"; int cacheMinutes = AppConfiguration.CacheMinutes; var cached = CacheHelper.GetItem(cacheKey); if (cached != null) { EventLogProvider.LogInformation( "CustomTableHelper", "CACHE_HIT_FisrtTime", $"[CacheKey: {cacheKey}] Returning cached list." ); return (IEnumerable< My_ViewModel >)cached; }

        return CacheHelper.Cache(cs = >
        {
            cs.CacheDependency = CacheHelper.GetCacheDependency("customtable.customtable_Table-name|all");

            EventLogProvider.LogInformation(
                "CustomTableHelper",
                "CACHE_MISS_FirstTime",
                $"[CacheKey: {cacheKey}] Fetching fresh list."
            );

            conditions ??= new List< IWhereCondition >();
            return GetTableContent< AlignerEducationViewModel >("customtable.tablename", conditions).ToList();

        }, new CacheSettings(cacheMinutes, cacheKey));
    }
    Event if i am using dependency key like this :- "customtable.tablename|all" or 
    customtableitem.<custom table class name>|all’ Still facing the same issue

Recent Answers


Juraj Ondrus answered on June 23, 2025 10:41

Could you please try following the samples from the documentation on setting cache dependencies? For example there is a custom table in the system which code name, including namespace is "customtable.sampletable" - so you need to use this as the code name in the key:
customtableitem.customtable.sampletable|all

0 votesVote for this answer Mark as a Correct answer

Chandni Negi answered on June 23, 2025 11:02

I Used that way also and read the documentation But i am still facing the same issue . whenever I update , create and delete something in my customtable the changes does not reflect On UI . [Cache is not missing ] . Until I did not restart the application

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on June 23, 2025 11:04

Where and how are you updating the records? The UI does not have caching and the cache dependency keys apply to the live site pages. If you are doing changes directly in the DB, then the app has no idea you are changing the records so it is not reloading the memory hash tables. You shall use the custom table API to change the values or, you need to restart the Kentico admin app to load new values.

0 votesVote for this answer Mark as a Correct answer

Chandni Negi answered on June 23, 2025 11:06 (last edited on June 23, 2025 11:51)

I am updating the records in customtable [CMS - admin site ]

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on June 23, 2025 12:17

OK, then where you do not see the updated data? Are you using some kind of caching on the IIS level?

0 votesVote for this answer Mark as a Correct answer

Chandni Negi answered on June 23, 2025 12:36 (last edited on June 23, 2025 12:37)

Without caching :- I have a page where data comes from customtable .When I added a new data in customtable it reflects on a page . With Caching :- When I add the data in customtable it does not comes on that page . For caching I added evnt log for cache hit and miss So whenever there is change occur in customtable the hit goes to Db and the event log shown as cache miss Here's i am getting cache hit instead of miss and that is why My changes are not reflecting on a page until I did not restart the application Basically my cache is not invalidating As i am trying to add the caching on this method public static IEnumerable

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on June 23, 2025 14:09

I am sorry but without knowing how to reproduce the issue it is hard to tell. IT seems that you are building something custom with custom code. I would recommend following the documentation and debugging the code. Keep on mind that the caching was intended to be used on the live site app's side.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.