Refactored redis key generation into function