def setUp(self): if not settings.configured: settings.configure() # importing in_memory only after django was initialized, otherwise it'll fail from hydro.cache.in_memory import InMemoryCache self.cache = InMemoryCache() self.cache.put('1', [1, 2, 3])
def __init__(self, params=None): self.in_mem = InMemoryCache() if params is None: params = dict() cache_table = params.get('cache_table', Configurator.MYSQL_CACHE_TABLE) cache_db = params.get('cache_db', Configurator.MYSQL_CACHE_DB) self.cache = DatabaseCache(cache_table, params={'NAME': cache_db}) # creating a table if not exist try: self.cache.get('a') except Exception as err: if err.args[0] in ( 1146, 1049 ): # 1146 - table doesn't exist, 1049 - unknown database? cmd = createcachetable.Command().execute( cache_table, **{ 'database': cache_db, 'verbosity': 2 }) else: raise