Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Clark Kent
FinderCache Explanation
6 de octubre de 2011 21:20
Respuesta

Clark Kent

Ranking: Regular Member

Mensajes: 100

Fecha de incorporación: 15 de abril de 2011

Mensajes recientes

Hi,

I want to know about how FinderCache works. Does it cache the query or the results? I have a scenario that i have two finders, so i need to know if Finder cache will cache the query or the results.

If it caches query is there anything that caches results.

If i caches result i want to know how it refreshes the cache results.

For example if i have a finder called findByCity which returns list of users, how long will it pick from the cache and what happens when someone adds a new user who has same city, will it update the cache or will it try to fetch everything again.

Regards,
Liferay Questions
Amos Fong
RE: FinderCache Explanation
10 de octubre de 2011 0:42
Respuesta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1817

Fecha de incorporación: 7 de octubre de 2008

Mensajes recientes

Hi,

Maybe the best example is to look at UserPersistenceImpl.java.

If you look at findByContactId(), it looks like it is caching the results:

 1        if (retrieveFromCache) {
 2            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
 3                    finderArgs, this);
 4        }
 5
 6        if (result == null) {
 7            ...
 8                    cacheResult(user);
 9
10                    if ((user.getContactId() != contactId)) {
11                        FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
12                            finderArgs, user);
13                    }


And you look at .updateImpl()

 1
 2        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
 3       
 4        ...
 5
 6        if (isNew ||
 7                (user.getContactId() != userModelImpl.getOriginalContactId())) {
 8            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
 9                new Object[] { Long.valueOf(user.getContactId()) }, user);
10        }
Clark Kent
RE: FinderCache Explanation
10 de octubre de 2011 2:37
Respuesta

Clark Kent

Ranking: Regular Member

Mensajes: 100

Fecha de incorporación: 15 de abril de 2011

Mensajes recientes

Thanks Amos. Exactly what i was looking for.

So it means i can create 2 finders with different names and they would act as two caches, even if the finder column is same.

for example consider two finders as below

findByLocation

findByCity

Both are finding on column city name suppose, then their results will be in separate caches?

Regards,
Liferay Questions
Amos Fong
RE: FinderCache Explanation
10 de octubre de 2011 6:14
Respuesta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1817

Fecha de incorporación: 7 de octubre de 2008

Mensajes recientes

yes I believe so. After you rebuild services, you can double check your PersistenceImpl class to make sure.
Clark Kent
RE: FinderCache Explanation
10 de octubre de 2011 22:33
Respuesta

Clark Kent

Ranking: Regular Member

Mensajes: 100

Fecha de incorporación: 15 de abril de 2011

Mensajes recientes

Thank you very very much emoticon
amir keshavarz
RE: FinderCache Explanation
24 de abril de 2012 22:00
Respuesta

amir keshavarz

Ranking: Junior Member

Mensajes: 29

Fecha de incorporación: 9 de octubre de 2010

Mensajes recientes

Hello,
Is there a manual way we could empty cashed results whereas tomcat is running.

Thanks
Amir
Amos Fong
RE: FinderCache Explanation
25 de abril de 2012 1:49
Respuesta

Amos Fong

LIFERAY STAFF

Ranking: Liferay Legend

Mensajes: 1817

Fecha de incorporación: 7 de octubre de 2008

Mensajes recientes

Amir,

I believe the "clear database cache" in control panel > server administration should do it.
amir keshavarz
RE: FinderCache Explanation
25 de abril de 2012 6:41
Respuesta

amir keshavarz

Ranking: Junior Member

Mensajes: 29

Fecha de incorporación: 9 de octubre de 2010

Mensajes recientes

Amos

Thank you emoticon