0

I have following large object (20KB) cached in memcache -

Product : 
{
    BasicInfo, //~5KB
    SellerId,  //int
    CityId,    //int
    AdditionalInfo //~15KB
}

This is being accessed at multiple places-

  1. At some place, only sellerId or cityId is required.
  2. At some places, only basicInfo is required.
  3. At some places, whole object is required.

So we are fetching whole object unnecessarily in 1st and 2nd cases while we only require some bytes. Should I store these separately in memcache (only problem is I need to invalidate multiple keys on updation)?

Is there any better way to handle these cases?

ctor
  • 101

1 Answers1

1

Since it's a cache, the best is definitively to store it in one place.

Ensuring cache integrety is already hard enough to do properly in large application to add more complexity.

The only problem you could run into is to use different criteria of search to retrieve the same object depending of the current use case. In this case you could need differents caches to handle the different kind of search criteria.

Walfrat
  • 3,536