Search code examples
pythongoogle-app-enginegoogle-cloud-datastore

Automatic deletion or expiration of GAE datastore entities


I'm building my first app with GAE to allow users to run elections, and I create an Election entity for each election.

To avoid storing too much data, I'd like to automatically delete an Election entity after a certain period of time -- say three months after the end of the election. Is it possible to do this automatically in GAE? Or do I need to do this manually?

If it matters, I'm using the Python interface.


Solution

  • Assuming you have a DateProperty on the entities indicating when the election ended, you can have a cron job search for any older than 3 months every night and delete them.