def get(wave_id, wavelet_id, email): """ Uses memcache or the datastore to fetch a single session by wave_id, wavelet_id and email @param wave_id: the id of the session to fetch @param wavelet_id: the id of the session to fetch @param email: the email of the session to fetch @return the session using the most efficient means possible or None if it couldn't be found """ key = base64.b64encode(memcacheConfig.PREFIX["SESSION"] + wave_id + wavelet_id + email) session = memcache.get(key) if not session == None: dbmigration.migratev1tov2([session]) return session else: query = Session.all() query.filter("wave_id =", wave_id) query.filter("wavelet_id =", wavelet_id) query.filter("email =", email) session = query.get() dbmigration.migratev1tov2([session]) memcache.add(key, session, time=memcacheConfig.DEFAULT_EXPIRE_SECS) return session
def fetch(wave_id, wavelet_id): """ Uses memcache or the datastore to get fetch sessions by wave_id and wavelet_id @param wave_id: the id of the session to fetch @param wavelet_id: the if of the session to fetch @return the sessions using the most efficient means possible or None if it couldn't be found """ key = base64.b64encode(memcacheConfig.PREFIX["SESSION"] + wave_id + wavelet_id) sessions = memcache.get(key) if not sessions == None: dbmigration.migratev1tov2(sessions) return sessions else: query = Session.all() query.filter("wave_id =", wave_id) query.filter("wavelet_id =", wavelet_id) sessions = query.fetch(100) dbmigration.migratev1tov2(sessions) memcache.add(key, sessions, time=memcacheConfig.DEFAULT_EXPIRE_SECS) return sessions