python脚本往redis加数据
#-*-coding:utf-8-*-
from rediscluster import StrictRedisCluster
import pymysql
import time
import cProfile
import timeit
def get_redis_connection():
rc = StrictRedisCluster(startup_nodes=[{'host':'10.101.32.97', 'port':1633}, {'host': '10.101.32.95', 'port':1633}, {'host': '10.101.32.96', 'port': 1633}],decode_responses=True)
return rc
def get_redis_value(command):
rc = get_redis_connection()
# Sspent = showCnt = Cspent = clickCnt = 0
allAppStoreSpent = allCashSpent = 0
for key in rc.scan_iter(match = command):
print(key)
re = rc.hgetall(key)
if 'cashSpent' in re:
i = int(re['cashSpent'])
allCashSpent = i + allCashSpent
elif 'appStoreDiscountSpent' in re:
x = int(re['appStoreDiscountSpent'])
allAppStoreSpent = x + allAppStoreSpent
else:
return False
return "allCashSpent: " + str(allCashSpent), "allAppStoreSpent: " + str(allAppStoreSpent)
if __name__ == "__main__":
valueN = get_redis_value('billing:advertiser:spent:????????????????????')
print(valueN)
#-*-coding:utf-8-*-
from rediscluster import StrictRedisCluster
import pymysql
import time
import cProfile
import timeit
def get_redis_connection():
rc = StrictRedisCluster(startup_nodes=[{'host':'10.101.82.101', 'port':6379}, {'host': '10.101.81.25', 'port':6379}, {'host': '10.101.82.31', 'port': 6379}],decode_responses=True)
return rc
def get_redis_value():
rc1 = get_redis_connection()
count = 1
while (count < 2):
#key="DL:1:8765432100000" + str(count) +":com.athinkthings.note.android.phone"
key="DL:IMEI:87654321000000" + str(count) +":com.athinkthings.note.android.phone"
rc1.hset(key, "creativeId", "20004641")
rc1.hset(key, "serviceTime", "1571194801000")
print ('The count is:', count)
count = count + 1
if __name__ == "__main__":
valueN = get_redis_value()
print(valueN)
最新文章
- 页面滚动到底部自动 Ajax 获取文章
- Oracle OCP 1Z0-053 Exam Topics
- Xilinx DCM 使用---- 输出频率问题
- 20145235 《Java程序设计》实验二
- CCS float vs clear
- IE 不兼容的几个js问题及解决方法1
- POJ-3207 Ikki&#39;s Story IV - Panda&#39;s Trick 2sat
- iOS textfield实现一行的数字限制,超出进行弹框
- MongoDB性能优化指南
- 数据库框架 Litepal
- Java习惯用法总结
- 在VMware中为Linux系统安装VM-Tools的详解教程
- 《第一行代码》学习笔记28-内容提供器Content Provider(1)
- perl eval函数
- DeviceIoControl的使用说明
- SVN和Git的一些用法总结
- 读《Java并发编程的艺术》(二)
- Eclipse使用JDBC小案例
- supergridcontrol记录,分页
- 11.redis_python