Base solution for your next web application
Open Closed

Cache per Tenant #1147


User avatar
0
david created

Hi all,

Nice job guys.

I was wondering what is the best way to implement cache per tenancy?

For example i have an entity that implements IMustHaveTenant.

i have a property named "name" which is unique for each tenant. I would like my appService getByName method, to return this entity from cache. However, if two tenants have an entry with same "name", cache returns the object of the first accessed.

What is the best practice to implement this functionality?


2 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    1. You can get current tenantId from session (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Abp-Session#DocUsingSession">http://www.aspnetboilerplate.com/Pages/ ... ingSession</a>).
    2. You can create a cache as described in document: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching">http://www.aspnetboilerplate.com/Pages/ ... ts/Caching</a>
    3. The key point is that: Generate cache key by combination of TenantId + Name.
  • User Avatar
    0
    david created

    That is what i was thinking of at the beginning. Just wondering if there was already something automated and missed it i.e like the way the fw is holding the tenancy permissions and settings.

    Thanks for the confirmation Hikalkan