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!