I'll split my answer based on the different needs. Based on what you have described, you are hitting the database for all information about a user multiple times. There are a few approaches on how to deal with that, without resorting to Redis.
#1: Security
Never use cached credentials to authenticate (confirm a user is who they claim to be). However, if you can delegate to some other service than a database that is designed to handle credentials, it would be wise to explore that. Some common options include:
- LDAPS authentication. It works well if you are developing an enterprise application and the user doesn't have to remember another set of credentials
- OAuth2 or OpenID providers. Works well for apps on the internet, and users can leverage their Facebook, Github, or Google identities to authenticate
- PKI. Really only works if the whole enterprise is built around this concept. The client certificate can only be presented to your system if it is valid, which means you don't even need a login form.
- IDAM server. Depending on your environment, you may need to use an IDentity And Management (IDAM) server to authenticate your users.
Using the external systems to authenticate still requires you to store the user's permissions to your application. That needs to be read in to ensure the user doesn't access things they are not allowed to.
#2: User Information
The ideal here is to only read the user's information once per session. A good way that my team has approached this is to use JWT tokens. The JWT token can be built in a way that it can be validated to ensure it has not been tampered with and has not expired. If you load that token with the information you need to access regularly, you don't have to hit your database or a Redis server. That token needs to be sent with every request.
We generate the token when the user is authenticated, and return it to the front end code. The front end then sends that token to the servers. When the token expires, the front end can either require re-authentication or use a token exchange concept. I.e. we would return 2 tokens, a session token with the current user information and a refresh token to exchange for a new session token.
The main concern here is to ensure your information is current enough. If the front end has to do a token exchange every 5 minutes, you only have that period of time that a user would have those old permissions.
#3: General guidance about business logic and caching
Ideally, cache access, management, and such really should be the responsibility of any "repositories" you have. The business logic will get overly complex if it has to know to retrieve information from the cache or the source database. If you keep that behind a Repository object, it can handle the cache access, invalidation, and management policies so you have only one place to fix things.