1 Star 0 Fork 1

ichao1214 / stock

forked from rzxxysy / stock 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
history_set.py 657 Bytes
一键复制 编辑 原始数据 按行查看 历史
rockyzsu 提交于 2020-08-20 00:30 . update
# 超时set
import datetime
class HistorySet(object):
def __init__(self,expire=1800):
self.data = {}
self.expire = expire
def add(self,value):
now = datetime.datetime.now()
expire = now + datetime.timedelta(seconds=self.expire)
try:
hash(value)
except:
raise ValueError('value not hashble')
else:
self.data.update({value:expire})
def is_expire(self,value):
# 没有过期 返回 False
if value not in self.data or self.data[value]<datetime.datetime.now():
return True
else:
return False
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ichao1214/stock.git
git@gitee.com:ichao1214/stock.git
ichao1214
stock
stock
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891