Skip to content

Commit

Permalink
gjg
Browse files Browse the repository at this point in the history
  • Loading branch information
you285168 committed Mar 16, 2020
1 parent baffe57 commit 0f445b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions charge/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _charge_ship(obj):


def _pay_logic(platform, param):
order_key = ORDER + param['order_id']
order_key = (ORDER + param['order_id']).replace(' ', '_')
if cache.get(order_key):
return
cache.set(order_key, 1, CACHE_TIME)
Expand Down Expand Up @@ -147,13 +147,13 @@ def charge_player(request):


def request_charge(sid, uid):
charge_key = CHARGE + uid
charge_key = (CHARGE + uid).replace(' ', '_')
if cache.get(charge_key):
return
objs = ChargeOrder.objects.filter(serverid=sid, account=uid, status=0)
result = True
for obj in objs:
order_key = ORDER + obj.order_id
order_key = (ORDER + obj.order_id).replace(' ', '_')
if not cache.get(order_key):
cache.set(order_key, 1, CACHE_TIME)
if not _charge_ship(obj):
Expand Down
1 change: 0 additions & 1 deletion common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def index(request):

def get_cache(request, key):
value = cache.get(key)
print(value)
return HttpResponse(value)


Expand Down
10 changes: 7 additions & 3 deletions push/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@
}


def _get_push_key(device):
return (PUSH_KEY + device).replace(' ', '_')


def _get_cache_device(device):
push_key = PUSH_KEY + device
push_key = _get_push_key(device)
return cache.get(push_key)


def _set_cache_device(obj):
push_key = PUSH_KEY + obj.device
push_key = _get_push_key(obj.device)
cache.set(push_key, {
'device': obj.device,
'token': obj.token,
Expand All @@ -58,7 +62,7 @@ def _set_cache_device(obj):


def _remove_cache_device(device):
push_key = PUSH_KEY + device
push_key = _get_push_key(device)
cache.delete(push_key)


Expand Down
4 changes: 2 additions & 2 deletions webaccount/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def clear_account_cache(obj):
param[2:] = iter(PLATFORM)
keys = {k: v for k, v in model_to_dict(obj, fields=param).items() if v and len(v) > 0}
for key, value in keys.items():
cachekey = key + value
cachekey = (key + value).replace(' ', '_')
cache.delete(cachekey)


Expand Down Expand Up @@ -74,7 +74,7 @@ def _get_account_detail(obj):

def get_cache_account(**kwargs):
for key, value in kwargs.items():
cachekey = key + str(value)
cachekey = (key + str(value)).replace(' ', '_')
break
data = cache.get(cachekey)
if not data:
Expand Down

0 comments on commit 0f445b3

Please sign in to comment.