I’ve read this but still can’t get it.
I want to do is a book store.
There are lots of book objects and each book has two counters.
One counter is to record the number of people like it.
Another is to record the number of people hate it.
Obviously, I need to make the counter incremented in transactions in case more than 5 people like or hate a book in the same time, right?
My questions are:
1. How to make book and the counter in the same entity group so that I can use them in the same transactions.
2. How to implement a sharding counters? I don’t understand why (here in the third example) we need to have ShardedCounter, Counter and GeneralCounterShard and how do I use them?
3. Could anyone give me an example? I’m using JDO.
Thanks for any advice!
Are you really afraid that more than 5 people update the counters of the same book in the same second? that would be the sign of a huge traffic on your app. If so, you’ll probably have more important problems to solve than the fact the a counter might be off by one or two votes.
I would simply make the counters part of the
Bookentity:Keep it simple, and change your design if and only if you have a problem.