Skip to content

Add maxBytesLocalDisk support for Ehcache 2#282

Closed
Copilot wants to merge 1 commit intosupport/ehcache2from
copilot/62-fix-issue-ehcache2
Closed

Add maxBytesLocalDisk support for Ehcache 2#282
Copilot wants to merge 1 commit intosupport/ehcache2from
copilot/62-fix-issue-ehcache2

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

setMaxBytesLocalDisk was missing from the Ehcache 2 adapter, making it impossible to enforce a disk-size ceiling on MyBatis caches.

Changes

  • AbstractEhcacheCache — adds setMaxBytesLocalDisk(long) and a protected rebuildCacheWith(CacheConfiguration) template method. Ehcache 2 enforces mutual exclusivity between maxBytesLocalDisk and maxEntriesLocalDisk, and prohibits switching disk pool types on a live cache instance; the setter works around this by constructing a fresh CacheConfiguration (preserving TTI/TTL/heap/eviction-policy) and replacing the running cache via the CacheManager.

  • EhBlockingCache — overrides rebuildCacheWith to re-apply the BlockingCache decorator after the underlying cache is replaced.

  • EhcacheTest — adds shouldSetMaxBytesLocalDisk verifying the byte limit is applied, maxEntriesLocalDisk is cleared, and the cache remains operational after the rebuild.

<!-- ehcache.xml or MyBatis mapper cache config -->
<cache type="org.mybatis.caches.ehcache.EhcacheCache">
  <property name="maxBytesLocalDisk" value="10485760"/> <!-- 10 MB -->
</cache>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix issue #62 for ehcache2 users Fix maxBytesLocalDisk support in Ehcache 2 (support/ehcache2 backport of #62) Mar 7, 2026
Copilot AI changed the title Fix maxBytesLocalDisk support in Ehcache 2 (support/ehcache2 backport of #62) Add maxBytesLocalDisk support for Ehcache 2 Mar 7, 2026
@hazendaz hazendaz changed the base branch from master to support/ehcache2 March 7, 2026 21:44
@hazendaz hazendaz force-pushed the copilot/62-fix-issue-ehcache2 branch 2 times, most recently from c82c342 to d1394c4 Compare March 7, 2026 21:56
@coveralls
Copy link

coveralls commented Mar 7, 2026

Coverage Status

coverage: 74.444% (-2.4%) from 76.812%
when pulling 2fd8449 on copilot/62-fix-issue-ehcache2
into 1bd0e7b on support/ehcache2.

@hazendaz hazendaz marked this pull request as ready for review March 7, 2026 21:56
Co-Authored-By: hazendaz <975267+hazendaz@users.noreply.github.com>
@hazendaz hazendaz force-pushed the copilot/62-fix-issue-ehcache2 branch from d1394c4 to 2fd8449 Compare March 9, 2026 00:49
@hazendaz hazendaz closed this Mar 9, 2026
@hazendaz hazendaz deleted the copilot/62-fix-issue-ehcache2 branch March 9, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants