123456789101112131415161718192021222324252627282930 |
- import json
- from django.conf import settings
- from operation.models import LatestAppInfo
- from utils.redis.rkeys import LATEST_APP_INFO
- r = settings.REDIS_CACHE
- def set_latest_app(src=0):
- """ 设置最新 APP 信息 """
- try:
- appinfo = LatestAppInfo.objects.filter(src=src)[0].data
- except IndexError:
- appinfo = {}
- r.set(LATEST_APP_INFO % src, json.dumps(appinfo))
- return appinfo
- def get_latest_app(src=0):
- """ 获取最新 APP 信息 """
- return json.loads(r.get(LATEST_APP_INFO % src) or '{}') or set_latest_app(src)
|