问题
When caching https://github.com/JetBrains/xodus/blob/master/openAPI/src/main/java/jetbrains/exodus/env/Environment.java with EHCache it throws:
Caused by: org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'jetbrains.exodus.env.Environment'
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.getSerializerClassFor(DefaultSerializationProvider.java:136)
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.createSerializer(DefaultSerializationProvider.java:98)
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.createValueSerializer(DefaultSerializationProvider.java:90)
at org.ehcache.core.EhcacheManager.getStore(EhcacheManager.java:464)
... 92 more
Obviously, this means the class is not serializable by default. However, what would be the library that can serialize any object, I've tried XStream but it did not work.
Here's how I build the cache:
if(environmentCacheManager == null) {
environmentCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.withCache("environmentCache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, Environment.class,
ResourcePoolsBuilder.heap(100).offheap(100, MemoryUnit.MB))
.build())
.build(true);
}
来源:https://stackoverflow.com/questions/63791360/caching-objects-with-ehcache