Example #1
0
    def read_transaction(self, key):
        """Get a read transaction on a file cache item.

        Returns a ReadTransaction context manager and opens the cache file for
        reading.  You can use it like this:

           with file_cache_object.read_transaction(key) as cache_file:
               cache_file.read()

        """
        return ReadTransaction(self._get_lock(key),
                               acquire=lambda: open(self.cache_path(key)))
Example #2
0
 def read_transaction(self):
     """Get a read lock context manager for use in a `with` block."""
     return ReadTransaction(self.lock, self._read)
Example #3
0
 def read_transaction(self, timeout=_db_lock_timeout):
     """Get a read lock context manager for use in a `with` block."""
     return ReadTransaction(self.lock, self._read, timeout=timeout)