You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Kobe <rk...@mailcity.com> on 2016/03/12 08:05:24 UTC

Relation between CacheStore and IgniteCache

Hello...

I am trying to understand how CacheStore behaviour is inserted into
IgniteCache.
I see in the Javadoc of IgniteCache that the loadCache() method passes
optional arguments
to CacheStore.loadCache(). I do not understand this correlation.

Please explain?

/Kobe



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Relation between CacheStore and IgniteCache

Posted by Kobe <rk...@mailcity.com>.
Could anyone please confirm my understanding? That is, if I need to cache
distinct entities (attached to the same hibernate session), I must create
distinct IgniteCache instances?

Regards,

Kobe


Kobe wrote
> Denis,
> 
> I need to cache a collection of objects of different types (a collection
> of campuses &lt;Long, Campus&gt;, collection of &lt;Long, Building&gt;,
> and a collection of residents
> &lt;Long, Resident&gt;). Does this mean I have instantiate three distinct 
> caches 
>           IgniteCache&lt;Long, Campus&gt;,
>           IgniteCache&lt;Long, Building&gt;
> and     Ignite&lt;Long, Resident&gt;
> 
> and attach corresponding CacheStore entities? How would a SQL join across
> these entities work?
> Also, I am using HibernateSessionListener to populate these caches. Is
> there any gotcha I should be
> aware of wrt it?
> 
> thanx,
> 
> /Kobe
> Denis Magda wrote
>> Hi Kobe,
>> 
>> CacheStore is set for every IgniteCache using
>> CacheConfiguration.setCacheStoreFactory(...) method as it's shown in this
>> example [1].
>> 
>> IgniteCache.loadCache(...) parameters can be used to control a subset of
>> data that should be loaded from an underlying persistent storage into a
>> cache.
>> 
>> Also I would recommend to take a look at examples that showcase how the
>> store works in practice [2]
>> 
>> [1]
>> https://apacheignite.readme.io/docs/persistent-store#cachestore-example
>> [2]
>> https://github.com/apache/ignite/tree/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store
>> 
>> On Sat, Mar 12, 2016 at 10:05 AM, Kobe &lt;

>> rk_@

>> &gt; wrote:
>> 
>>>
>>> Hello...
>>>
>>> I am trying to understand how CacheStore behaviour is inserted into
>>> IgniteCache.
>>> I see in the Javadoc of IgniteCache that the loadCache() method passes
>>> optional arguments
>>> to CacheStore.loadCache(). I do not understand this correlation.
>>>
>>> Please explain?
>>>
>>> /Kobe
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471.html
>>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>>





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471p3479.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Relation between CacheStore and IgniteCache

Posted by Denis Magda <dm...@gridgain.com>.
Kobe,

Your understanding looks correct to me. It's always better to decouple 
different entities from each other and store them in relevant caches.
Here you can follow the same rules as when you work with a database 
where you create a table for each unique entity.

For every cache you have to set a CacheStore explicitly in its 
configuration.
SQL joins work out of the box in Ignite [1]. However you should properly 
collocate data to use joins when partitioned caches participate in a 
query [2]

Have nothing to add in relation to HibernateSessionListener.

[1] https://apacheignite.readme.io/docs/sql-queries#cross-cache-queries
[2] https://apacheignite.readme.io/docs/affinity-collocation

--
Denis

On 3/13/2016 2:12 AM, Kobe wrote:
> Denis,
>
> I need to cache a collection of objects of different types (a collection of
> campuses <Long, Campus>, collection of <Long, Building>, and a collection of
> residents
> <Long, Resident>). Does this mean I have instantiate three distinct  caches
>            IgniteCache<Long, Campus>,
>            IgniteCache<Long, Building>
> and     Ignite<Long, Resident>
>
> and attach corresponding CacheStore entities? How would a SQL join across
> these entities work?
> Also, I am using HibernateSessionListener to populate these caches. Is there
> any gotcha I should be
> aware of wrt it?
>
> thanx,
>
> /Kobe
>
>
> Denis Magda wrote
>> Hi Kobe,
>>
>> CacheStore is set for every IgniteCache using
>> CacheConfiguration.setCacheStoreFactory(...) method as it's shown in this
>> example [1].
>>
>> IgniteCache.loadCache(...) parameters can be used to control a subset of
>> data that should be loaded from an underlying persistent storage into a
>> cache.
>>
>> Also I would recommend to take a look at examples that showcase how the
>> store works in practice [2]
>>
>> [1]
>> https://apacheignite.readme.io/docs/persistent-store#cachestore-example
>> [2]
>> https://github.com/apache/ignite/tree/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store
>>
>> On Sat, Mar 12, 2016 at 10:05 AM, Kobe &lt;
>> rk_@
>> &gt; wrote:
>>
>>> Hello...
>>>
>>> I am trying to understand how CacheStore behaviour is inserted into
>>> IgniteCache.
>>> I see in the Javadoc of IgniteCache that the loadCache() method passes
>>> optional arguments
>>> to CacheStore.loadCache(). I do not understand this correlation.
>>>
>>> Please explain?
>>>
>>> /Kobe
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471.html
>>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>>
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471p3474.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Relation between CacheStore and IgniteCache

Posted by Kobe <rk...@mailcity.com>.
Denis,

I need to cache a collection of objects of different types (a collection of
campuses <Long, Campus>, collection of <Long, Building>, and a collection of
residents
<Long, Resident>). Does this mean I have instantiate three distinct  caches 
          IgniteCache<Long, Campus>,
          IgniteCache<Long, Building>
and     Ignite<Long, Resident>

and attach corresponding CacheStore entities? How would a SQL join across
these entities work?
Also, I am using HibernateSessionListener to populate these caches. Is there
any gotcha I should be
aware of wrt it?

thanx,

/Kobe


Denis Magda wrote
> Hi Kobe,
> 
> CacheStore is set for every IgniteCache using
> CacheConfiguration.setCacheStoreFactory(...) method as it's shown in this
> example [1].
> 
> IgniteCache.loadCache(...) parameters can be used to control a subset of
> data that should be loaded from an underlying persistent storage into a
> cache.
> 
> Also I would recommend to take a look at examples that showcase how the
> store works in practice [2]
> 
> [1]
> https://apacheignite.readme.io/docs/persistent-store#cachestore-example
> [2]
> https://github.com/apache/ignite/tree/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store
> 
> On Sat, Mar 12, 2016 at 10:05 AM, Kobe &lt;

> rk_@

> &gt; wrote:
> 
>>
>> Hello...
>>
>> I am trying to understand how CacheStore behaviour is inserted into
>> IgniteCache.
>> I see in the Javadoc of IgniteCache that the loadCache() method passes
>> optional arguments
>> to CacheStore.loadCache(). I do not understand this correlation.
>>
>> Please explain?
>>
>> /Kobe
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471.html
>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471p3474.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Relation between CacheStore and IgniteCache

Posted by Denis Magda <dm...@gridgain.com>.
Hi Kobe,

CacheStore is set for every IgniteCache using
CacheConfiguration.setCacheStoreFactory(...) method as it's shown in this
example [1].

IgniteCache.loadCache(...) parameters can be used to control a subset of
data that should be loaded from an underlying persistent storage into a
cache.

Also I would recommend to take a look at examples that showcase how the
store works in practice [2]

[1] https://apacheignite.readme.io/docs/persistent-store#cachestore-example
[2]
https://github.com/apache/ignite/tree/master/examples/src/main/java/org/apache/ignite/examples/datagrid/store

On Sat, Mar 12, 2016 at 10:05 AM, Kobe <rk...@mailcity.com> wrote:

>
> Hello...
>
> I am trying to understand how CacheStore behaviour is inserted into
> IgniteCache.
> I see in the Javadoc of IgniteCache that the loadCache() method passes
> optional arguments
> to CacheStore.loadCache(). I do not understand this correlation.
>
> Please explain?
>
> /Kobe
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Relation-between-CacheStore-K-V-and-IgniteCache-K-V-tp3471.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>