示例#1
0
    def test_get_with_delete_expired(self):
        millenium_unixtime = 946706400

        # Set the already expired item
        self.assertTrue(Cache.set(self.key, self.value,
            time=millenium_unixtime))
        # Check if it exists in the Datastore
        self.assertTrue(Item.all().filter('cache_key =', self.key).get())
        # Try to get it should return None, but force to keep the item
        self.assertEquals(Cache.get(self.key, delete_expired=False), None)
        # Check again if it exists in the Datastore
        self.assertTrue(Item.all().filter('cache_key =', self.key).get())
        # Try to get it should return None and delete the item
        self.assertEquals(Cache.get(self.key), None)
        # Check again if it exists in the Datastore, it should have been del.
        self.assertFalse(Item.all().filter('cache_key =', self.key).get())
示例#2
0
 def test_flush_all(self):
     self.assertTrue(Cache.set('1', self.value))
     self.assertTrue(Cache.set('2', self.value))
     self.assertTrue(Cache.flush_all())
     self.assertFalse(Item.all().count())