You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Pim D <pi...@ns.nl> on 2018/01/20 16:34:03 UTC
CacheStore example for partitioned cache backed with a postgres
database
Hi,
I can't seem to find a good example on how to implement a CacheStoreAdapter
that also writes cache updates to a postgres database.
I've tried the standaard CacheJdbcStoreFactory, yet it does not write the
updates (even with read and write through set to true and WAL disabled).
I've created my own implementation of de CacheStoreAdapter and load(key) is
being called (and working), but Ignite does not call the write nor the
delete actions of the store.
I've been looking at the cassandra example, but that one is way more complex
and seems to require a lot more than I need (and thus adds even more
complexity).
Many thanks in advance,
Pim
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: CacheStore example for partitioned cache backed with a postgres database
Posted by Andrey Mashenkov <an...@gmail.com>.
Pim,
Why you set WAL disabled? Do you use native ignite persistence together
with CacheStore?
If so, it is not supported, either native persistence or CacheStore should
be used, but not both.
On Sat, Jan 20, 2018 at 7:34 PM, Pim D <pi...@ns.nl> wrote:
> Hi,
>
> I can't seem to find a good example on how to implement a CacheStoreAdapter
> that also writes cache updates to a postgres database.
>
> I've tried the standaard CacheJdbcStoreFactory, yet it does not write the
> updates (even with read and write through set to true and WAL disabled).
> I've created my own implementation of de CacheStoreAdapter and load(key) is
> being called (and working), but Ignite does not call the write nor the
> delete actions of the store.
>
> I've been looking at the cassandra example, but that one is way more
> complex
> and seems to require a lot more than I need (and thus adds even more
> complexity).
>
> Many thanks in advance,
> Pim
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
--
Best regards,
Andrey V. Mashenkov
Re: CacheStoreAdapter write and delete are not being called by
Ignite's GridCacheStoreManager
Posted by Pim D <pi...@ns.nl>.
Hi Slava,
Guess I overlooked that part, thanx!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: CacheStoreAdapter write and delete are not being called by
Ignite's GridCacheStoreManager
Posted by "slava.koptilin" <sl...@gmail.com>.
Hi Pim,
Well, you only configure CacheLoaderFactory which is used when a cache is
read-through or when loading data into a cache via the Cache#loadAll()
method.
So, you need to provide a CacheWriter implementation in order to enable
write-through behavior.
Please see, CacheConfiguration#setCacheWriterFactory().
Apache Ignite provides a convenient method
CacheConfiguration#setCacheStoreFactory() which allows specifying cache
store factory(please see CacheStore class). Something like as follows:
CacheConfiguration cacheCfg = new CacheConfiguration();
cacheCfg.setName("PlayerScores");
cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(PlayerScoreStoreAdapter.class));
...
Simple examples can be found here:
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
https://github.com/apache/ignite/blob/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
Thanks,
Slava.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/