How do I limit the properties of caches (size, expiry, etc.)?

You can configure Coherence to automatically configure the properties of a cache by adding new <caching-schemes> and <caching-scheme-mapping> elements to the <local-cache-factory-config> element present in the tangosol-coherence.xml file (located at the root of coherence.jar). Reference the coherence.dtd file, also located at the root of the coherence.jar, in the same jar to understand the XML structure.

Example:

<caching-schemes>
  <scheme>
  <scheme-name>default</scheme-name>
  <high-units>-1</high-units>
</scheme>

<!-- keep 1000 items and hold each one only for 30 minutes -->
<scheme>
  <scheme-name>max-1000-expiry</scheme-name>
  <high-units>1000</high-units>
  <expiry-delay>1800</expiry-delay>
</scheme>

<!-- keep 100000 items and flush the cache once a day -->
<scheme>
  <scheme-name>max-100000-flush</scheme-name>
  <high-units>100000</high-units>
  <flush-delay>86400</flush-delay>
  </scheme>
</caching-schemes>

Now map those to your caches:

<caching-scheme-mapping>
  <cache-name>message*</cache-name>
  <scheme-name>max-100000-flush</scheme-name>
</caching-scheme-mapping>
<caching-scheme-mapping>
  <cache-name>threads</cache-name>
  <scheme-name>max-1000-expiry</scheme-name>
</caching-scheme-mapping>
<caching-scheme-mapping>
  <cache-name>*</cache-name>
  <scheme-name>default</scheme-name>
</caching-scheme-mapping>

Now when you ask for any cache with the cache name starting with "message", it will be size-limited at 100000 entries and flush entirely once every day. Similary, if you ask for a cache by the name "threads", it will be size-limited to 1000 entries and each entry will expire 30 minutes after it has been last updated.

Configurable Cache Properties

Do not replace the "default" scheme unless you want to replace the behavior of ALL the caches obtained through Coherence.