将字符串添加到列表中并在特定时间段内使每个项目到期 [英] Add strings to list and expiry each item in certain period of time

查看:60
本文介绍了将字符串添加到列表中并在特定时间段内使每个项目到期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

请告诉我以下要求的最佳方法。

please let me know the best approach for the below requirements.

我正在尝试添加字符串项在列表中,不允许使用重复的密钥。

i am trying to add string items to the list, duplicate keys are not allowed.

我想要 设置每个项目的到期时间。当时间过去密钥应该从列表中删除。 

i wanted to  set the expiry time for each item. When time elapse key should remove from list. 

请帮助我达到上述要求。

please help me to achieve above requirements.

谢谢, 

Ravi

推荐答案

我认为缓存是最好的选择,因为它可能会过期物品自动。如果你是的话,请查看

MemoryCache
正好在进行中。
I think a cache would be the best option here as it can expire items automatically. Take a look at MemoryCache if you are fine with it being in process.


这篇关于将字符串添加到列表中并在特定时间段内使每个项目到期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆