I am attempting to delete an object from the GAE datastore and then cache the remaining datastore objects with memcache. The object is being successfully deleted, but for some reason the python log and the memcache are not recognizing that one was deleted. The Datastore Viewer shows that the object is deleted, but the log says the the length of the items is not changing... also the memcache is just caching all of the items, as if no deletion is happening. Any advice you can give is much appreciated.
Python code:
yesterday = datetime.now()-timedelta(days=1) # one day ago
sessions = db.GqlQuery("SELECT * FROM MentorAvailSessions WHERE created > :1", yesterday).fetch(1000) #pulling list of all objects
logging.info('************** len before deleting a session: %s*********' % len(sessions)) # shows a length of 3
for session in sessions:
if (session.session_id == end_session_id) and (session.user == user_info.username):
session.delete();
remaining_sessions = db.GqlQuery("SELECT * FROM MentorAvailSessions WHERE created > :1", yesterday).fetch(1000) #pulling list of just the remaining objects after deleting one
logging.info('** len of remaining sessions: %s' % len(remaining_sessions)) # still shows a length of 3 after session.delete
memcache.set('mentor_avail_sessions_cache', remaining_sessions, time=50000) # is caching all three items instead of just the remaining 2