py-redis set the expiration time


hashlib Import
"" "MD5 encryption" ""
URL = 'https://www.baidu.com'
h1 of hashlib.md5 = ()
h1.update (url.encode ())
Print ( 'prior to the MD5:' + URL)
Print ( 'after the MD5 as:' + h1.hexdigest ())
r.lpush ( 'URL', { 'Key': h1.hexdigest (), 'type': 0, 'Time': A datetime.datetime . .now () the strftime ( '% m% D% the Y')})

# r.setex ( 'URL', { 'Key': h1.hexdigest (), 'type': 0, 'Time': datetime. DateTime.Now (). the strftime ( '% m%% the Y D')}, 50)
# r.lrange RES = ( 'URL', 0, r.llen ( 'URL'))
# the time.sleep (. 11)
= the datetime.timedelta time (Days =. 1)
Print (time)

"" "of R & lt Redis" ""
#expire function is to set the expiration time (key, time) time may be a second default datetime.timedelta () type, automatic calculation function

r.expire ( 'url', time)

Guess you like

Origin www.cnblogs.com/yjybupt/p/11002474.html