Jump to content

sessions


pawel

Recommended Posts

hi,

How is the session meant to be used? Should we start a session and re-use it between various calls (aka global singleton)? Or should we start a new session for each api interaction?

#1 in case of the option one how is the cache invalidated? Do we need to invalidate it ourselves in some event listener? From our initial tests it doesn't seem to be automatically updated/invalidated.

#2 in case of the option two do we need to close the session after each interaction or will it be closed once the variable is cleaned by garbage collection?

a side question:

how do we stop ftrack logger in maya? it spams script editor the moment a session is initialized.

Link to comment
Share on other sites

Hi @pawel

we are using one session as a global session.

Quote

#1 in case of the option one how is the cache invalidated?

why do you want to invalidate the cache? Normally you don't need to do it.

If the session is running for a long time, when you want commit a change, first you query the ftrack entity again and then you commit, just to be sure that the entity didn't change in the meantime. 

 

 

Link to comment
Share on other sites

9 minutes ago, Remus Avram said:

Hi @pawel

we are using one session as a global session.

why do you want to invalidate the cache? Normally you don't need to do it.

If the session is running for a long time, when you want commit a change, first you query the ftrack entity again and then you commit, just to be sure that the entity didn't change in the meantime. 

 

 

2

hi @Remus Avram

if I query an entity again and it was previously retrieved and is already cached it will be returned from the cache, won't it? That's how I understand the caching mechanism.  Otherwise what is actually cached if every query fetches new data anyway? I will test it a bit more. Currently I have a session per call but it is troublesome to make sure all sessions are closed properly.

cheers.

Link to comment
Share on other sites

38 minutes ago, pawel said:

if I query an entity again and it was previously retrieved and is already cached it will be returned from the cache, won't it? 

If you are using session.get() yes, but if you are using session.query() it will query the DB again.

41 minutes ago, pawel said:

 Otherwise what is actually cached if every query fetches new data anyway?

I think the cache makes sens in some cases, for example if only one generic user is allowed to change some data. But in most of the cases you want to query the DB again before changing it to be sure that nobody already updated it.

44 minutes ago, pawel said:

Currently I have a session per call but it is troublesome to make sure all sessions are closed properly.

I think the open/close session is not the main problem of having a session per call. 

Having a session per call it will slow down the process.

Link to comment
Share on other sites

6 hours ago, Yas Opisso said:

Hi @pawel:

As for the ftrack issue in Maya, are you using Maya 2017? If so, Maya 2017 update 4 seemed to fix this issue for me.

we are using update 3 at the moment.

thank you for the tip. will test it in update 4. cheers.

Link to comment
Share on other sites

14 hours ago, Remus Avram said:

If you are using session.get() yes, but if you are using session.query() it will query the DB again.

I think the cache makes sens in some cases, for example if only one generic user is allowed to change some data. But in most of the cases you want to query the DB again before changing it to be sure that nobody already updated it.

I think the open/close session is not the main problem of having a session per call. 

Having a session per call it will slow down the process.

one session it is then. Thank you mate.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...