=== modified file 'django/core/cache/backends/base.py'
|
|
|
54 | 54 | Returns True if the key is in the cache and has not expired. |
55 | 55 | """ |
56 | 56 | return self.get(key) is not None |
| 57 | |
| 58 | def __contains__(self, key): |
| 59 | """ |
| 60 | Allow use of 'in' operator. |
| 61 | """ |
| 62 | return self.has_key(key) |
=== modified file 'tests/regressiontests/cache/tests.py'
|
|
|
46 | 46 | self.assertEqual(cache.has_key("hello"), True) |
47 | 47 | self.assertEqual(cache.has_key("goodbye"), False) |
48 | 48 | |
| 49 | def test_in(self): |
| 50 | # has_key |
| 51 | cache.set("hello", "goodbye") |
| 52 | self.assertEqual("hello" in cache, True) |
| 53 | self.assertEqual("goodbye" in cache, False) |
| 54 | |
49 | 55 | def test_data_types(self): |
50 | 56 | # test data types |
51 | 57 | stuff = { |