# LocalCache

Hi

We have finally managed to get GigaSpaces XAP and Hibernate 2nd level into production. It is currently running ok however we have experienced some performance problems but it is not related to GigaSpaces but how we implement ACL security. We have a master local topology for ACL security however we are finding that we are making quite a number of remote calls to the space to get acl/user details. As ACL/User details details don't change much I have proposed using a LocalCache for this. I remember some time ago that by appending useLocalCache to the space url enables the use of LocalCache for the application. However I have noticed that there are still significant hits to the master cache.

I looked around the documentation for GigaSpaces XAP and came across this:

http://www.gigaspaces.com/wiki/display/XAP66/LocalCacheandLocalViewComponents

Which shows how to use GigaSpaces localcache but it is related to the configuration of GigaSpaces API. I tried implementing this solution rather than appending useLocalCache to the url, howvever I was getting a classcastexception while constructing the LocalCacheSpaceFactoryBean. I tried the following:

<bean id="localCacheSpace" class="org.openspaces.core.space.cache.LocalCacheSpaceFactoryBean">
<property name="space" ref="space" />
<property name="updateMode" value="PULL" />
</bean>

the space is created by a class which extends UrlSpaceFactoryBean to add some custom initialisation behaviour. Unfortunately I am home now and can't connect to my workstation to copy the stacktrace (I will be able to do it later today once the RDC is working correctly).

What is teh recommended approach for dealing with localcache?

Any help would be appreciated.

Thanks!

This thread was imported from the previous forum.
For your reference, the original is available here

edit retag close merge delete

Sort by » oldest newest most voted

Why won't you have this:

<prop key="hibernate.cache.provider_class">org.openspaces.hibernate.cache.SimpleMapCacheProvider</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="gigaspace.hibernate.cache.url">jini://*/*/spaceName?uselocalcache=true</prop>
more

Hi Shay

Thanks for your reply. We are using the space directly for storing ACL/UserDetails (via SpaceClass wrapper). We experienced several issues(transactional) when combining hibernate cache and acls. I presume I can do useLocalCache=true and use the GigaSpaces API directly and have a localcache. As I mentioned earlier due to the fact we make several calls to get security details for objects we want to make have a local copy of the space and let the applications use the local instead of hitting the master space.

So I'm assuming that I don't need to configure a localspace as mentioned in http://www.gigaspaces.com/wiki/displa... and I can just configure the space url to useLocalCache=true for example:

{code} <os-core:space id="space" url="jini://*/*/space?useLocalCache=true"/> <os-core:giga-space id="gigaSpace" space="space"/> {code}

In my application code I can then use

( 2009-05-10 00:38:32 -0500 )edit

In such a case the application should construct the local cache via the following: {code} UrlSpaceConfigurer urlSpaceConfigurer = new UrlSpaceConfigurer("jini:////space"); IJSpace localSpaceProxy = new LocalCacheSpaceConfigurer(urlSpaceConfigurer.space()).updateMode(UpdateMode.PULL).localCache(); GigaSpace gigaspace = new GigaSpaceConfigurer(localSpaceProxy).gigaSpace(); {code}

or via: {code} <os-core:space id="space" url="jini://*/*/space"/> <os-core:local-cache id="localCacheSpace" space="space" update-mode="PULL"/> {code} Shay

Edited by: Shay Hassidim on May 10, 2009 5:03 AM

( 2009-05-10 05:01:25 -0500 )edit

Hi

I have another quick question and I was wondering if you might be able to answer (probably silly question anyway), what are supported GigaSpaces API for LocalCache? Are the following supported for reading from the local cache:

Cheers Amin

( 2009-05-22 08:18:11 -0500 )edit

Yes, local cache is implementation of the same GigaSpace interface. the only thing that is not supported is clear method.

Eitan

( 2009-05-22 08:26:20 -0500 )edit

Hi

Thanks for your reply. Operations using a transaction however are made to the master cache rather than the local cache I presume. We are experiencing performance issues which I have been asked to investigate. We have the following topologies:

hibernateCache ---> hibernate 2nd level cache distributedCache ---> storing user acl entries and session information for session replication

We are using transactional cache for hibernate and also disabled query cache as this was causing a lot of locking issues. Unfortunately our application that has been developed relied heavily on the hibernate 2nd level cache and as a result we are starting to see poor performance. We are not using local cache for hibernate as it does not provide any advantages as transaction operations (which is about 95% of all our operations) are made against the remoted space.

We opted for primary back because we also found sync-replication bad when we had more than 3 application nodes. Replication between nodes effectively made the application halt to the ground. I believe that primary back is the only solution to enable multiple application nodes to work, is this a correct assumption? Also that is expected behaviour for transactions and local cache and effectively having a local cache for transactional operation is meaningless?

Cheers Amin

( 2009-05-22 08:42:07 -0500 )edit