fixed memory cache bug

- clear() size bug fix
- improve put and check size code