~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/core/cache/backends/locmem.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
 
78
78
    def set(self, key, value, timeout=None):
79
79
        self._lock.writer_enters()
80
 
        # Python 2.3 and 2.4 don't allow combined try-except-finally blocks.
 
80
        # Python 2.4 doesn't allow combined try-except-finally blocks.
81
81
        try:
82
82
            try:
83
83
                self._set(key, pickle.dumps(value), timeout)
110
110
 
111
111
    def _cull(self):
112
112
        if self._cull_frequency == 0:
113
 
            self._cache.clear()
114
 
            self._expire_info.clear()
 
113
            self.clear()
115
114
        else:
116
115
            doomed = [k for (i, k) in enumerate(self._cache) if i % self._cull_frequency == 0]
117
116
            for k in doomed:
133
132
            self._delete(key)
134
133
        finally:
135
134
            self._lock.writer_leaves()
 
135
 
 
136
    def clear(self):
 
137
        self._cache.clear()
 
138
        self._expire_info.clear()