[UPDATE] add checking on opening session before try to get the cache

It’s not an optimised way but should work for the prototype