mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-22 00:56:37 +03:00
Added method to flush single import_key in storage
This commit is contained in:
parent
85a785eb59
commit
842f43b242
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user