我有这个 ConcurrentMap
ConcurrentMap<String, Byte[]> companyLogo = new MapMaker()
.concurrencyLevel(Runtime.getRuntime().availableProcessors())
.weakKeys()
.initialCapacity(1000)
.expiration(24, TimeUnit.HOURS)
.makeMap();
还有这段代码
companyLogo.put("cpr48124", ArrayUtils.toObject(resize (request, ((Byte[])request.getSession().getAttribute(COMPANY_LOGO_KEY+ imageId)))));
companyLogo.get("cpr48124");
但是 companyLogo.get("cpr48124");
为空。怎么可能?
最佳答案
我不熟悉 MapMaker
,但我猜 weakKeys
可能是您的问题。
很可能是您的新条目的“弱点”使其不可用,因为没有其他引用。
关于java ConcurrentMap 获取空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40285480/