Trim and clear memory cache

Added methods that allow to clear and trim the memory cache