0
votes

I want to implement counter on App Engine. The obvious way is to use memcache for this purpose. But docs state that memcache is not reliable and I have to implement fall-back method in case counter in memcache has wrong value or missing. I can easily detect that key is missing, but how can I know that counter has wrong value? I am speaking about following situation:

  1. key = 30
  2. incr(key), key = 31
  3. key is flushed by GAE
  4. incr(key), key = 1

Is there any trick I don't know (checksum for numbers that works with memcache?)? Should I really care about such situation?

Some probably useless details:

  • Counter will have values in range 0-10000.
  • Counters should be live 1 hour. I store them in datastore every hour.
  • I am using Go.

Thanks.

2

2 Answers

3
votes
0
votes

I would use an open-source library for this instead. Have you seen this one?

https://github.com/oodlemud/appengine-counter