| 501 | self.assertEqual(expensive_calculation.num_runs, runs_before_cache_read) |
| 502 | |
| 503 | def test_expiration(self): |
| 504 | # Cache values can be set to expire |
| 505 | cache.set("expire1", "very quickly", 1) |
| 506 | cache.set("expire2", "very quickly", 1) |
| 507 | cache.set("expire3", "very quickly", 1) |
| 508 | |
| 509 | time.sleep(2) |
| 510 | self.assertIsNone(cache.get("expire1")) |
| 511 | |
| 512 | self.assertIs(cache.add("expire2", "newvalue"), True) |
| 513 | self.assertEqual(cache.get("expire2"), "newvalue") |
| 514 | self.assertIs(cache.has_key("expire3"), False) |
| 515 | |
| 516 | @retry() |
| 517 | def test_touch(self): |