init memcache only when caching enabled.