If you can live with occasional losses, just use memcache incr() -
memcache can still loose data**
Then have periodic tasks, that 'writes' the value from memcache into
the datastore.
* Unless you use backends. They are resident, and less likly to suffer
memory loss. But in general from what I understand backends wouldnt be
a good fit to implement the actual API serving.
** But if you experience regular data loss, just increase the
frequency of tasks.
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>
>
Depends party on how many clients you have. One of the issues you face
is that can't "query" memcache to see what keys there are waiting to
be written. So you either have to just try them all, or maintain some
sort of list.
If a small number (under say 1000?) then the cron running a check for
all clients would probably work find.
But if many more than that, esp if only a few are active in any
period, then its a huge overhead, to check them all, when many will
still be missing/zero.
In which case when a hit from a client comes, you queue up a task
unique to the client. Set an eta for an hour later. Or similar.
That task then fires later, and wipes the current value from memcache,
and adds it to the datastore.
A nice feature is can use task names to prevent adding more tasks for
a given user. So name the task like "client_month_day_hour" or
similar. Then successive attempts (because you try on every hit) will
just fail. The first one exists and will run.
(But the cron version is easier. Try that first. If its not keeping
up, or too slow, the try the task queue version)
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-appengine/-/7ZZEf6HRSoIJ.