Memcached-Challenge
Hi everybody
I'm wondering what you would do and come up with a little challenge: I develop a webapp using Grails, Couchbase (Memcached Bucket) and Mysql as persistence. Now, I have following domain classes (simplified):
Product: Can be in one category
Category: Can have nested children, and have multiple products.
I need to access all product objects by id which led me to the idea to store all products in one big Memcached-entry with a key: PRODUCTMAP and as value, all product attributes as array, like: [productId1: [title: 'title'], productId2: [title: 'title']]
If I browse to category 4, I simply get my map categoryMap with value [cateoryId: [productId1, productId2]]
I also can list all products of a certain category by providing that id.
The bad thing about this is that I always have to put back everything (ie the whole productMap) if I modify a single product.
Who can give advice how to realize that?
Any help will be appreciated!
Thanks,
Best
Sullivan
Hello,
Have you tried to use another approach where your store in memory each product separately ( one entry for each product) and keep only if necessary the list of product in the category?
Is that possible?
You can for example prefix the product ID by the category if the product id is not unique.
Also if you start to change the model, have you looked at moving the data from MySQL+Couchbase Memcache to a 100% Couchbase (with Couchbase Bucket)?
Regards
Tug
@tgrall