Memcache delete - memcache.get_stats()

1 view
Skip to first unread message

kordi

unread,
Aug 29, 2008, 4:36:17 AM8/29/08
to Google App Engine
Hello,

i found something very strange. If you make a memcache.delete call,
the item is delete from the memcache (you cannot access it via
memcache.get), but it occurs still in "memcache.get_stats()" .

Shouldnt it be "deleted" from the stats as well.

Nikolai

Alexander Kojevnikov

unread,
Aug 29, 2008, 6:01:11 AM8/29/08
to Google App Engine
I suppose there's a background process that updates the stats from
time to time, that is the stats are not necessary up to date.

From the documentation:

All of these statistics may reset due to various transient conditions.
They provide the best information available at the time of being
called.

bowman...@gmail.com

unread,
Aug 29, 2008, 8:55:28 AM8/29/08
to Google App Engine
FYI: You can see a good example of this at the appengine-utilities
session demo. http://gaeutilities.appspot.com/session

Just keep clicking "Delete your session" over and over. Either this is
an example of what the OP is talking about, or I have a bug. I've
double checked the delete method several times as I noticed this. Just
hadn't had a chance to file a report on it yet. You can see items
being added, so the stats appear to be updated with the additions but
not deletions?

source - http://code.google.com/p/appengine-utitlies/source/browse/tags/.7.1/appengine_utilities/sessions.py

Specific method: (additional inline comments added for this post)

def _delete_session(self):
"""
Delete the session and all session data for the sid passed.

NOTES FOR GOOGLE GROUP POST - In the datastore, there is a
model for each
session, and another model for the session data entries.
Session data is refers to the
session model using a ReferenceProperty(). The memcache object
is an object
that is the session key prefixed by sid-:
('sid-'+str(self.session.key())). The object is
dictionary object with all the key - value pairs from session
data.

The delete process is
1. delete all the session data from the datastore
2. delete the memcache object
3. delete the session from the datastore
"""

sessiondata = self._get()
# delete from datastore
if sessiondata is not None:
for sd in sessiondata:
sd.delete()
# delete from memcache
memcache.delete('sid-'+str(self.session.key()))
# delete the session now that all items that reference it are
deleted.
self.session.delete()
# if the event class has been loaded, fire off the
sessionDeleted event
if 'AEU_Events' in __main__.__dict__:
__main__.AEU_Events.fire_event('sessionDelete')


On Aug 29, 6:01 am, Alexander Kojevnikov <alexan...@kojevnikov.com>
wrote:
Reply all
Reply to author
Forward
0 new messages