'Best Approach for Multi-Tenant Caching with Yii 1.1 on X2 CRM

I am working on a CRM project using the X2 Engine CRM. The app has File based caching built in and it works well when deployed as a single tenant application. However, I am using this in a multi-tenant capacity where there is a single code base with multiple databases (one for each client using the app).

The app has the ability for users to define custom CRM fields and add them forms for different records.

When User A creates a custom field and accesses the page with that field, the app caches the HTML for that form, as well as for the data model, in the file based cache.

Thus, when User B accesses the app with a different database, the app tries to serve the cached HTML with the custom field that does not exist in their database. This causes an error and the ONLY user who can load the app is User A until I go and manually delete the cache. It then rebuilds the cache based on User B and everything works fine until User A goes in and loads the page again.

In the interim, I have turned off caching to avoid this issue, but I am trying to decide the best approach to caching this site. The app does have support for Redis and other caches, but I don't know that this will solve the issue.

I think what I need is a caching solution that stores a cache for each subdomain (i.e. Client Database). Or a solution that stores the cache in the active database so that each user has a different cache.

I am running this on an EC2 Instance with Debian 10 LAMP stack (using Maria DB, but migrating to and RDS with Aurora).

Any thoughts would be awesome!



Solution 1:[1]

I figured out that Yii allows you to specify different caching configurations. Inswitch this to CDbCache and now it cashes each site in the users database.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick Villaume