I\'m trying to configure Ehcache (version 2.5) such that it never forgets items. I\'m configuring programmatically and I haven\'t touched any of the configuration XML files
When using ARC, or byte based cache configuration, Ehcache will try to protect your system of an OOME. Configuring the cache as you did, tells ehcache that you want this cache to use at most 1 megabyte of heap. Overflowing to disk tells Ehcache to overflow elements to disk when the heap is filled to the threshold. Now, the key set for this cache will still remain on heap. And, as Ehcache still tries to protect you from OOME, it will need to evict from disk, as soon as the key set can't be held in memory anymore.
I slightly changed your config to use 10MB, I can get 32K entries in the Cache. If I change your key to be smaller (only the Integer instance), I can get 46K entries in the Cache. But basically, this configuration your using is to restrictive, as Ehcache will never be able to hold that much on disk, with the key set on heap. Hope this clarifies a bit.
If you really have a use case where you need to put a lot on disk and minimize on-heap storage, you might want to look into http://ehcache.org/documentation/user-guide/storage-options#enterprise-diskstore