1. Use `cache` class so now it generates memcache events. 2. Do not use nested if (simplify code) 3. Use local variables. 4. Remove redundant checks.