Currently, I have implemented a system where I store a refresh token in a JavaScript array as well as in each user's information table. When a user requests data, I first check the token in the array. If the token matches one in the array, I loop through the array to confirm its presence. If the token is not found in the array, I then look up the user's information table for the token.
My concern is regarding performance: Would using an array for token storage be better than performing a database lookup if the number of users increases in the future?
JavaScript:
validateToken.forEach(element => {
if (token == element) {
retun true;
}
});
If not found in the array, perform a database lookup for the token.