如果存储满了,如何控制内存
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like A clear and concise description of what you want to happen.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
你指的是 storage 不是内存吧?
目前的策略比较简单,每分钟遍历一遍把过期的数据删掉。 还没想好怎么把各种策略(比如FIFO、LRU)集成进来。
指的是 storage。 实际项目中可能有人把过期时间设置的很长,以至于不能及时清除数据,导致存储满了。 目前工作的项目中,计划当storage存储使用大于一个值后,采用FIFO,或者按过期时间远近两种策略清除缓存,不太确定的是什么时候计算storage使用量比较好,如果每次存的时候计算,会不会太频繁了。
我想想... 在 storage 里存这样一个数据:每条记录的保存时间,过期时间,上次使用时间、大小等信息。 基于这个数据就可以做一些策略控制?