5a6
> from django.core.cache import cache
10a12
> import md5
123a126
>         self._cacheme = True
482a486,509
>     def nocache(self):
>         self._cacheme = False
>         return self
> 
>     def cache(self,time,force=False):
>         """
>         Caches QuerySet objects if their cachekey is not already in the cache.
>         Returns the original QuerySet. Will cache the new result if force=True.
>         """
>         self._cacheme = True
>         # must cache for a positive number of seconds
>         if time > 0:
>             cachekey = self._cachekey()
>             # only cache if it is not currently cached
>             if force or not cache.get(cachekey):
>                 cache.set(cachekey,self,time)
>             return self
>         else:
>             raise Exception('Django ORM caching error: You must specify a positive time interval.')
> 
>     def _cachekey(self):
>         m = md5.new(str(self.query))
>         return m.hexdigest()
> 
599a627,634
>         # make sure to set new object's cacheme value to old value
>         c._cacheme = self._cacheme
>         # only test against the cache if cacheme variable is True
>         if c._cacheme:
>             cachekey = c._cachekey()
>             cached = cache.get(cachekey)
>             if cached:
>                 c = cached
