设置配置缓存过期时间30天

dependabot/npm_and_yarn/fir_admin/url-parse-1.5.10
nineven 3 years ago
parent 14f60d4f8d
commit 44cfd03cee
  1. 5
      fir_ser/api/management/commands/expire_config_caches.py
  2. 4
      fir_ser/api/tasks.py
  3. 6
      fir_ser/api/utils/sysconfig.py

@ -6,5 +6,8 @@ from api.tasks import clean_config_cache
class Command(BaseCommand):
help = 'Expire config caches'
def add_arguments(self, parser):
parser.add_argument('key', nargs='?', type=str, default='*')
def handle(self, *args, **options):
clean_config_cache()
clean_config_cache(options.get('key', '*'))

@ -86,8 +86,8 @@ def start_api_sever_do_clean():
invalid_config_cache()
def clean_config_cache():
invalid_config_cache()
def clean_config_cache(key):
invalid_config_cache(key)
@app.task

@ -22,8 +22,8 @@ class SystemConfigSerializer(serializers.ModelSerializer):
fields = "__all__"
def invalid_config_cache():
SystemConfigCache('*').del_many()
def invalid_config_cache(key='*'):
SystemConfigCache(key).del_many()
# def make_json_value(value, default):
@ -57,7 +57,7 @@ class ConfigCacheBase(object):
if d_key != key and data is not None:
db_data['value'] = data
db_data['key'] = key
cache.set_storage_cache(db_data, timeout=0)
cache.set_storage_cache(db_data, timeout=60 * 60 * 24 * 30)
return db_data.get('value')
def set_value(self, key, value):

Loading…
Cancel
Save