You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
743 B
22 lines
743 B
8 months ago
|
import random
|
||
|
import json
|
||
|
import time
|
||
|
|
||
|
from django_redis import get_redis_connection
|
||
|
|
||
|
def random_params(_user_info, _handle_data):
|
||
|
print('_user_info', _user_info)
|
||
|
print('_handle_data', _handle_data)
|
||
|
redis_key_api = f'dspt_api_{_user_info["user_ip"]}_{_user_info["member_type"]}_{_user_info["api"]}_random'
|
||
|
redis_conn = get_redis_connection()
|
||
|
if redis_conn.get(redis_key_api):
|
||
|
redis_conn.delete(redis_key_api)
|
||
|
data = {
|
||
|
'api': _user_info["api"],
|
||
|
'member_type': _user_info["member_type"],
|
||
|
'format': _user_info["format"],
|
||
|
'timestamp': int(time.time()*1000),
|
||
|
'user_data': [random.choice(_handle_data['res']['data'])],
|
||
|
}
|
||
|
redis_conn.set(redis_key_api, json.dumps(data))
|