Refactor and fixed redis expiration issue