ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkulichenko <valentin.kuliche...@gmail.com>
Subject Re: Read Only Cache initialization from DB
Date Tue, 18 Aug 2015 04:48:51 GMT
diopek wrote
> In my use case, basically certain caches will be populated from DB tables
> on demand for read-only purposes. Updates are being done at certain dates
> directly in database tables. I believe one way to do that is to use
> standard cache api (put) to populate the cache without backing up with
> CacheStore. 
> I also saw this CacheLoadOnlyStoreAdapter&lt;K,V,I&gt; class, but I am not
> sure is that good fit to initialize cache from DB tables and eliminates
> updates to persistent store.
> Regarding your statement, is there a way (configuration) to define
> immutable caches?
>>>Note that setting cacheCfg.setWriteThrough(false) will only prevent you
from writing to persistence store, but cache will still be updated if put()
or remove() method is called.

OK, it looks like you want to read-through from the database and invalidate
the data in cache once it's updated in the database. Is this right?

To implement read-through you should configure your store with load() method
implemented and set CacheConfiguration.setReadThrough(true), like described
here: https://apacheignite.readme.io/docs/persistent-store

For invalidation you have two options:
1. Have a DB trigger that will somehow (e.g., via REST request) remove
required mappings from the cache. You can use IgniteCache.clear(key) method
for this.
2. Use expiration. Define it via CacheConfiguration.setExpiryPolicyFactory()
configuration property and entries in the cache will be invalidated based on
provided policy.

Will this work for you?


View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Read-Only-Cache-initialization-from-DB-tp1017p1026.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

View raw message