--- trigger: always_on --- # Redis Rules - **Format:** `{app}:{layer}:{entity}:{action}:{id}` (e.g., `app:cache:user:123`) - **Rules:** All lowercase, separated by colons `:`, max 50 chars. - **Mandatory TTL:** Every key MUST have an expiration time to avoid memory leaks. - **Commands:** Use `SCAN`, `HSCAN`, `SSCAN`. NEVER use `KEYS *` (blocks server). - **Structures:** Use `Hash` for objects, `String` for simple values/JSON, `Set`/`List` for collections. - **Invalidation:** Use tags (e.g., `app:tags:user`) to group and delete related cache keys.