0

I want to add a Mapper to cache with java api in MyBatis. I try this way and add Mapper's namespace to caches, but the statements of the Mapper still has no cache. is there any way to add Mapper statements into the cache?

...
Cache cache = (new CacheBuilder("package.name.SampleEntity"))
      .implementation(PerpetualCache.class)
      .addDecorator(LruCache.class)
      .clearInterval(null)
      .size(null)
      .readWrite(true)
      .blocking(false)
      .properties(new Properties())
      .build();

sqlSessionFactory.getConfiguration().addCache(cache);
...
MHSaffari
  • 858
  • 1
  • 16
  • 39
  • I don't think there is a public API for that. Why can't you use `` or `@CacheNamespace`? – ave Jan 17 '23 at 20:21
  • @ave Because the mapper files are in an external library and I don't have access to its code. – MHSaffari Jan 18 '23 at 16:07
  • I see. That usage is not considered in the current design, apparently. I've never used it, but Spring's `@Cacheable` could be a viable alternative. – ave Jan 19 '23 at 06:36

0 Answers0