Reputation: 668
i have the following code
def get(self):
date = datetime.date.today()
loc_query = Location.all()
last_cursor = memcache.get('location_cursor')
if last_cursor: loc_query.with_cursor(last_cursor)
loc_result = loc_query.fetch(1)
for loc in loc_result:
self.record(loc, date)
taskqueue.add(
url='/task/query/simplegeo',
params={'date':date, 'locid':loc.key().id()}
)
if len(loc_result):
memcache.add('location_cursor', loc_query.cursor())
taskqueue.add(url='/task/count/', method='GET')
else:
memcache.add('location_cursor', None)
i don't know what i'm doing wrong, but i am getting the same cursor which is not the effect i wanted. why isn't the cursor moving?
Upvotes: 0
Views: 334
Reputation: 881675
You're misusing memcache.add
, which is documented here as:
Sets a key's value, if and only if the item is not already in memcache.
So you're never storing any cursor different from the first one. Use memcache.set
instead, which
Sets a key's value, regardless of previous contents in cache.
Note that this has nothing to do with cursors -- it's all about proper use of memcache
!
Upvotes: 5