def memcache_retrieve(self): '''If the data needs to be cached, cache it.''' if self._memcache_key is None or Context.env_unit_test(): return None if self._memcache is None: self._memcache = Memcache() return self._memcache.retrieve(self._memcache_key)
def memcache_purge(self): '''If the data has been cached, purge it.''' if self._memcache_key is None or Context.env_unit_test(): return if self._memcache is None: self._memcache = Memcache() self._memcache.purge(self._memcache_key)
def memcache_store(self, data): '''If there is data and it should be cached, cache it.''' if self._memcache_key is None or Context.env_unit_test(): return if self._memcache is None: self._memcache = Memcache() self._memcache.store(self._memcache_key, data, self._memcache_ttl, self._memcache_ttl)
def commit(self, ignore_exceptions=False): if self.__postgresql is None: if not ignore_exceptions: raise DataStoreException( 'transaction cannot be committed because a database ' + 'connection has not been established yet') else: if Context.env_unit_test(): return else: self.connect() self.__postgresql.commit()
def commit(self, ignore_exceptions=False): if self.__mysql is None: if not ignore_exceptions: raise DataStoreException( 'transaction cannot be committed because a database ' + 'connection has not been established yet' ) else: if Context.env_unit_test(): return else: self.connect() self.__mysql.commit()
def memcache_store(self, data): '''If there is data and it should be cached, cache it.''' if self._memcache_key is None or Context.env_unit_test(): return if self._memcache is None: self._memcache = Memcache() self._memcache.store( self._memcache_key, data, self._memcache_ttl, self._memcache_ttl)