This discussion is archived
1 Reply Latest reply: Jul 21, 2010 8:07 AM by 416683 RSS

Size unbounded, distributed, persistent cache with overflow?

700290 Newbie
Currently Being Moderated
Hi all.

As the subject indicates, I'm in need of a size unbounded, distributed, persistent cache with overflow. What I would like to have is a cache that stores a portion of the cache's data in memory on the storage node, and the overflow data persisted to the database. The cache has the potential (which is unlikely, but needs to be accounted for) of becoming quite large in MB, and the data must be persisted. What I don't want to have to do is size the storage node's local-scheme for a "worst case size scenario" because that would take all the memory away from my other caches! Is this even possible?

I've found examples on how to build either persistent or overflow definitions, but I'm not sure it's possible to combine all of these aspects into one cache definition. Here's as close as i've gotten:


-----
<cache-mapping>
<cache-name>MyExampleCache</cache-name>
<scheme-name>MyExampleCacheScheme</scheme-name>
</cache-mapping>

<near-scheme>
<scheme-name>MyExampleCacheScheme</scheme-name>
<front-scheme>
<local-scheme>
<scheme-name>MyExampleCacheInMemoryScheme</scheme-name>

<!-- hold 100 objects in the client's local memory -->
<high-units>100</high-units>
<eviction-policy>HYBRID</eviction-policy>
</local-scheme>
</front-scheme>
<back-scheme>
<distributed-scheme>
<scheme-ref>MyExampleCacheJPAScheme</scheme-ref>
</distributed-scheme>
</back-scheme>
</near-scheme>

<distributed-scheme>
<scheme-name>MyExampleCacheJPAScheme</scheme-name>
<service-name>MyExampleCacheJPAService</service-name>
<autostart>true</autostart>
<thread-count>3</thread-count>
<partition-count>127</partition-count>
<backing-map-scheme>

<!-- read-write for persistence -->
<read-write-backing-map-scheme>
<write-delay>3s</write-delay>
<rollback-cachestore-failures>true</rollback-cachestore-failures>
<internal-cache-scheme>
<local-scheme>
<scheme-name>MyExampleCacheDistributedInMemoryScheme</scheme-name>

<!-- 5242880 is 5MB in the storage node VM -->
<high-units>5242880</high-units>

<eviction-policy>HYBRID</eviction-policy>
<unit-calculator>BINARY</unit-calculator>
</local-scheme>
</internal-cache-scheme>

<!-- Define the cache scheme, backed to Oracle, sizing is unlimited -->
<cachestore-scheme>
<class-scheme>
<class-name>
com.tangosol.coherence.jpa.JpaCacheStore
</class-name>
<init-params>
<!-- snip for brevity -->
</init-params>
</class-scheme>
</cachestore-scheme>
</read-write-backing-map-scheme>
</backing-map-scheme>
</distributed-scheme>

-----
So I've limited the storage node VM size to 5MB, but I believe this limits the entire cache to 5MB (assume a 1 node cluster, just for fun), which isn't what I'm after. I'd like 5MB in memory, and say, 500MB additional, less frequently used data at my beck and call in Oracle. Again, I'm not even sure this is possible :)

Any help would be appreciated.
  • 1. Re: Size unbounded, distributed, persistent cache with overflow?
    416683 Explorer
    Currently Being Moderated
    Hi user4556517.

    What you want to use is an "overflow-scheme".

    http://coherence.oracle.com/display/COH35UG/overflow-scheme

    For an example with configuration:
    http://coherence.oracle.com/display/COH35UG/Sample+Cache+Configurations#SampleCacheConfigurations-Partitionedcachewithoverflow

    For the external scheme, there are several OOTB implementations: http://coherence.oracle.com/display/COH35UG/external-scheme

    External schemes use a pluggable store manager to store and retrieve binary key value pairs. Supported store managers include:

    * async-store-manager - a wrapper providing asynchronous write capabilities for of other store manager implementations
    * custom-store-manager - allows definition of custom implementations of store managers
    * bdb-store-manager - uses Berkeley Database JE to implement an on-disk cache
    * lh-file-manager - uses a Coherence LH on-disk database cache
    * nio-file-manager - uses NIO to implement memory-mapped file based cache
    * nio-memory-manager - uses NIO to implement an off JVM heap, in-memory cache

    Here is the configuration for overflow to disk. You would need to change the external external scheme store manager to use a db.
    <distributed-scheme>
      <scheme-name>SamplePartitionedOverflowScheme</scheme-name>
      <backing-map-scheme>
        <overflow-scheme>
          <scheme-ref>SampleOverflowScheme</scheme-ref>
        </overflow-scheme>
      </backing-map-scheme>
      <backup-storage>
        <type>scheme</type>
        <!-- Note that the cache's backup storage also uses the same overflow scheme which allows for backup data to be overflowed to disk. -->
        <scheme-name>SampleOverflowScheme</scheme-name>
      </backup-storage>
    </distributed-scheme>
    
    <overflow-scheme>
      <scheme-name>SampleOverflowScheme</scheme-name>
      <front-scheme>
        <local-scheme>
          <scheme-ref>SampleMemoryLimitedScheme</scheme-ref>
        </local-scheme>
      </front-scheme>
      <back-scheme>
        <external-scheme>
          <scheme-ref>SampleDiskScheme</scheme-ref>
        </external-scheme>
      </back-scheme>
    </overflow-scheme>
    
    <local-scheme>
       <scheme-name>SampleMemoryLimitedScheme</scheme-name>
       <high-units>1000</high-units>
    </local-scheme>
    
    <external-scheme>
      <scheme-name>SampleDiskScheme</scheme-name>
      <lh-file-manager/>
    </external-scheme>
    Let me know if you have any further questions.
    -John

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points