diff --git a/src/django_clickhouse/clickhouse_models.py b/src/django_clickhouse/clickhouse_models.py index 1bb28e7..1b34c8d 100644 --- a/src/django_clickhouse/clickhouse_models.py +++ b/src/django_clickhouse/clickhouse_models.py @@ -58,6 +58,8 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)): sync_storage = None sync_delay = None sync_lock_timeout = None + + # This flag gives ability to disable to_db_string while inserting data, if it is already formatted sync_formatted_tuples = False # This attribute is initialized in metaclass, as it must get model class as a parameter diff --git a/src/django_clickhouse/storages.py b/src/django_clickhouse/storages.py index e16a5ac..84720a4 100644 --- a/src/django_clickhouse/storages.py +++ b/src/django_clickhouse/storages.py @@ -280,6 +280,16 @@ class RedisStorage(with_metaclass(SingletonMeta, Storage)): key = "%s.sync.%s.queue" % (config.STATSD_PREFIX, model.get_import_key()) statsd.gauge(key, 0) + def flush_import_key(self, import_key): + keys = [ + self.REDIS_KEY_RANK_TEMPLATE.format(import_key=import_key), + self.REDIS_KEY_OPS_TEMPLATE.format(import_key=import_key), + self.REDIS_KEY_LOCK.format(import_key=import_key), + self.REDIS_KEY_LAST_SYNC_TS.format(import_key=import_key) + ] + self._redis.delete(*keys) + statsd.gauge("%s.sync.%s.queue" % (config.STATSD_PREFIX, import_key), 0) + def get_last_sync_time(self, import_key): sync_ts_key = self.REDIS_KEY_LAST_SYNC_TS.format(import_key=import_key) res = self._redis.get(sync_ts_key)