Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix: set memcache expiration time to session expiration time

  -- didn't set any expiration in the past, so it would remain in memcache until the session was terminated or memcache evicted it
  • Loading branch information...
commit f23ed0b7581b62bd6511f74a9c0986f65b166a64 1 parent f7349cf
@dound authored
View
2  gaesessions/__init__.py
@@ -311,7 +311,7 @@ def save(self, persist_even_if_using_cookie=False):
# latest data will only be in the backend, so expire data cookies we set
self.cookie_data = ''
- memcache.set(self.sid, pdump, namespace='') # may fail if memcache is down
+ memcache.set(self.sid, pdump, namespace='', time=self.get_expiration()) # may fail if memcache is down
# persist the session to the datastore
if dirty is Session.DIRTY_BUT_DONT_PERSIST_TO_DB or self.no_datastore:
View
6 tests/SessionTester.py
@@ -159,6 +159,12 @@ def finish_request_and_check(self, expect_failure=False):
if self.ss.sid == ANY_SID:
self.ss.sid = remote_ss.sid
+ # expire the memcache if it is past the expir time (this doesn't handle
+ # expiration mid-usage, but the test cases workaround that)
+ has_expired_now = self._get_expiration() <= int(time.time())
+ if has_expired_now:
+ self.ss.in_mc = False
+
if expect_failure:
assert remote_ss.in_db is False, "failure expected: data should not be in the datastore"
assert remote_ss.in_mc is False, "failure expected: data should not be in memcache"
View
1  tests/test_gaesessions.py
@@ -285,7 +285,6 @@ def check_expiration(no_datastore, cookie_only_threshold):
# generate some sessions
num_to_start = 20
sessions_which_expire_shortly = (1, 3, 8, 9, 11)
- expir_time = int(time.time() + 1)
sts = []
for i in xrange(num_to_start):
stnew = SessionTester(st=st)
Please sign in to comment.
Something went wrong with that request. Please try again.