Update class query : Fix cache functionnality

Rewrite cache functionnality for a better integration and bug fixing.