reduce database access when login/register
add set_cache and drop_cache function for context