简体   繁体   English

从 Static Hash Map 清除密钥的实用程序

[英]Utility to clear key from Static Hash Map

I have a Servlet based Web App which has a Helper class containing a static HashMap.我有一个基于 Servlet 的 Web 应用程序,它有一个 Helper class,其中包含一个 static Z063A5BC470661C971C79E。 Data is loaded into the HashMap from DB once on Servlet init.数据在 Servlet 初始化时从 DB 加载到 HashMap 中。 I need to create a utility to clear specific keys from the HashMap and reload those specific keys from the DB.我需要创建一个实用程序来清除 HashMap 中的特定密钥并从数据库中重新加载这些特定密钥。 What is the best way to implement a Utility to do this?实现实用程序的最佳方法是什么?

If you can use something other than HashMap you could look into Google guava library has a built in support for this( https://github.com/google/guava/wiki/CachesExplained ).如果您可以使用 HashMap 以外的其他东西,您可以查看 Google guava 库对此的内置支持( https://github.com/google/guava/wiki/CachesExplained )。 Hope that helps希望有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM