You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by vkulichenko <va...@gmail.com> on 2015/08/18 03:43:27 UTC
Re: Read Only Cache initialization from DB
diopek wrote
> What is the best approach to implement READ-ONLY cache.
>
> Setting cacheCfg.setWriteThrough(false); would disable write operations
> even underlying CacheStore has has write and delete methods implemented.
> Or, I should also add OperationNotSupported kind of exception to
> write/delete operations to eliminate inadvertent updates in underlying
> persistence store.
Hi,
Can you please provide more details on your use case? What do you mean by
read-only cache? How are you going to populate the cache and what read
operations will you perform?
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.
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Read-Only-Cache-initialization-from-DB-tp1017p1021.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Read Only Cache initialization from DB
Posted by "kcheng.mvp" <kc...@gmail.com>.
Yes, that's what I want. but I am blocked by the issue
https://issues.apache.org/jira/browse/IGNITE-1246
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Read-Only-Cache-initialization-from-DB-tp1017p1027.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Read Only Cache initialization from DB
Posted by vkulichenko <va...@gmail.com>.
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<K,V,I> 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?
-Val
--
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.