wrote some codes for memory cache