拍爱

rapp.py 578B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. import json
  3. from django.conf import settings
  4. from operation.models import LatestAppInfo
  5. from utils.redis.rkeys import LATEST_APP_INFO
  6. r = settings.REDIS_CACHE
  7. # 最新 APP 相关
  8. def set_latest_app():
  9. """ 设置最新 APP 信息 """
  10. try:
  11. appinfo = LatestAppInfo.objects.all()[0].data
  12. except IndexError:
  13. appinfo = {}
  14. r.set(LATEST_APP_INFO, json.dumps(appinfo))
  15. return appinfo
  16. def get_latest_app():
  17. """ 获取最新 APP 信息 """
  18. return json.loads(r.get(LATEST_APP_INFO) or '{}') or set_latest_app()