Use Cache class instead of global variables