Пример #1
0
# coding: utf-8

"""
@Author: Well
@Date: 2016 - 04 - 20
"""

from app.util.well_fun_redis_conn import REDIS

r = REDIS(host='10.1.249.139', port=6379, db=0)
a = r.zrange_byscore_withscores("hhub:RoomPrice:3115", 16090002, 161201002)
for i in a:
    if '520574391055' in i[0] and '2016-04-21' in i[0]:
        print i[1]
        json_ = i[0]

print json_
json_2 = """{"LocatorID":"520574531144","BizDay":"2016-04-21T00:00:00","IsRoom":true,"RatePlanCode":"COGHZ2","InvTypeCode":"QEC","BaseByGuestAmtList":[{"AmountAfterTax":172.01,"AmountBeforeTax":150.01,"CurrencyCode":"CNY","NumberOfGuests":"1"},{"AmountAfterTax":0.0,"AmountBeforeTax":0.0,"CurrencyCode":"CNY","NumberOfGuests":"2"},{"AmountAfterTax":0.0,"AmountBeforeTax":0.0,"CurrencyCode":"CNY","NumberOfGuests":"3"}],"PushDate":"2016-03-14T17:56:45.882+08:00","MealPlanCodes":["14"]}
"""
#
# # r.zset_rem("hhub:RoomPrice:3115",json_)
r.zset_add("hhub:RoomPrice:3115",*(161121002,json_2))
# coding: utf-8

"""
@Author: Well
@Date: 2015 - 12 - 18
"""

from __future__ import unicode_literals
from __future__ import print_function

from app.util.well_fun_redis_conn import REDIS
import datetime
import json

r = REDIS(host='10.1.249.136', port=6379, db=0)
print (r.ping())
print (r.key_exits("dp:2000014:A:6"))

# print r.zrangebyscore("dp:2000014:A:6", 0, 999)

start_date = datetime.datetime.strptime("2015-11-11", '%Y-%m-%d')
biz_date_str = "2015-12-24"
biz_date = datetime.datetime.strptime(biz_date_str, '%Y-%m-%d')
now = datetime.datetime.now()
day_no = (now - start_date).days
print (len(r.zrangebyscore("dp:2000014:A:6", day_no, day_no)))

print (type(r.zrangebyscore("dp:2000014:A:6", day_no, day_no)[0]))