Search code examples
oraclecachingrefreshoracle-coherence

Oracle Coherence Refresh-Ahead: refresh doesn't work if the cache is queried earlier than soft-expiration period


I got strange behaviour of refresh ahead functionality. Here is my configuration:

<cache-config>
    <defaults>
        <serializer>pof</serializer>
        <socket-provider system-property="tangosol.coherence.socketprovider"/>
    </defaults>
    <caching-scheme-mapping>
        <cache-mapping>
            <cache-name>sample</cache-name>
            <scheme-name>extend-near-distributed</scheme-name>
        </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>

        <near-scheme>
            <scheme-name>extend-near-distributed</scheme-name>
            <front-scheme>
                <local-scheme>
                    <high-units>20000</high-units>
                    <expiry-delay>10s</expiry-delay>
                </local-scheme>
            </front-scheme>
            <back-scheme>
                <distributed-scheme>
                    <scheme-ref>distributed</scheme-ref>
                </distributed-scheme>
            </back-scheme>
            <invalidation-strategy>all</invalidation-strategy>
        </near-scheme>

        <distributed-scheme>
            <scheme-name>distributed</scheme-name>
            <service-name>sample</service-name>
            <thread-count>20</thread-count>
            <backing-map-scheme>
                <read-write-backing-map-scheme>
                    <internal-cache-scheme>
                        <local-scheme>
                            <expiry-delay>10s</expiry-delay>
                        </local-scheme>
                    </internal-cache-scheme>
                    <cachestore-scheme>
                        <class-scheme>
                            <class-name>
                                com.sample.CustomCacheStore
                            </class-name>
                        </class-scheme>
                    </cachestore-scheme>
                    <refresh-ahead-factor>0.5</refresh-ahead-factor>
                </read-write-backing-map-scheme>
            </backing-map-scheme>
            <autostart>true</autostart>
        </distributed-scheme>
    </caching-schemes>
</cache-config>

and if I request my service with a period of 6s (10s*0.5) seconds everything is fine. I have no delaying in response(except for the first time), but if i change a period to 3 seconds for example, then i start getting delays every 10 seconds. I have no idea why it is happening. It looks like if i request my service before expectable period (from 5 to 10 seconds) asynchronous loading doesn't happen even if after that i request it again. Is there any explanation of it and how can i bypass this behaviour?

Thanks


Solution

  • The problem has been solved. The reason why i've got such a situation is that front-scheme didn't notify the back-scheme because of the same expiration time. In a few words, to use refresh-ahead functionality with near cache you have to set expiration time of front-scheme equal to soft-expiration time(in that case it will be 10s*0.5).