mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-25 02:23:45 +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_storage = None
|
||||||
sync_delay = None
|
sync_delay = None
|
||||||
sync_lock_timeout = 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
|
sync_formatted_tuples = False
|
||||||
|
|
||||||
# This attribute is initialized in metaclass, as it must get model class as a parameter
|
# 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())
|
key = "%s.sync.%s.queue" % (config.STATSD_PREFIX, model.get_import_key())
|
||||||
statsd.gauge(key, 0)
|
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):
|
def get_last_sync_time(self, import_key):
|
||||||
sync_ts_key = self.REDIS_KEY_LAST_SYNC_TS.format(import_key=import_key)
|
sync_ts_key = self.REDIS_KEY_LAST_SYNC_TS.format(import_key=import_key)
|
||||||
res = self._redis.get(sync_ts_key)
|
res = self._redis.get(sync_ts_key)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user