How do I limit a cache size by bytes instead of by the entry count?

For a partitioned cache, use the attached cache extension which measures its units in bytes. Configure the high-units to be in bytes, as shown below. Be sure to specify the class of the cache extension, too.

  <!-- this is the max bytes of memory: 1MB -->

Since the MemoryLimitedCache implementation only supports Binary values, it can be easily used as the backing map for a partitioned cache – but not as an object cache (e.g. within the front side of a Near Cache):

      <!-- this is the max  count of objects to keep locally on the  "client" side -->
      <service-name>dist-limited</servic e-name>
          <class-name>c om.tangosol.examples.coherence.MemoryLimitedCache</class-name>
          <!-- this&n bsp;is the max bytes of memory to use pe r JVM on the "server" side -->
          <high-units>1 000000</high-units>

There is a <unit-calculator> element in the <local scheme> element. Adding <unit-calculator>BINARY</unit-calculator> will cause the low-units/high-units elements to control maximum byte count rather than object count.

Attachments: (text/plain)