Java 如何使用ClassValue作为具有put()方法的类型缓存?

Java 如何使用ClassValue作为具有put()方法的类型缓存?,java,caching,Java,Caching,我想使用ClassValue作为类型缓存。但是,我想给一个类型分配一些值。为此,我不能使用computeValue(),因为映射是在外部定义的,即不是预先确定的 我看到ClassValue中有一个put方法,但它不可访问 在我的ClassValue实现中使用Map也是没有意义的 我想知道使用类名而不是class是否是一个更好的选择 如何使用ClassValue作为缓存

我想使用
ClassValue
作为类型缓存。但是,我想给一个类型分配一些值。为此,我不能使用
computeValue()
,因为映射是在外部定义的,即不是预先确定的

我看到
ClassValue
中有一个
put
方法,但它不可访问

在我的
ClassValue
实现中使用
Map
也是没有意义的

我想知道使用类名而不是
class
是否是一个更好的选择

如何使用
ClassValue
作为缓存