Welcome Guest, Not a member yet? Register   Sign In
Where to store often used datas?
#1

(This post was last modified: 12-26-2024, 01:05 AM by 4usol.)

Hello,

I would like to discuss how best to handle data that is used frequently in the project.

For example (think about lot datas of this kind for example in a forum)
- User IDs, usernames
- Roleids, role names,
etc.

Normaly on every single point i run a database-query to get this infos.

I would like to reduce the database call for this simple data, especially because it normally doesn't change or rarely changes.

I'm thinking about storing all of these values in the session, but I'm not sure if that will have a positive impact on server cache etc?

Another idea was to use local browser storage. At this point I'm worried for safety reasons. Maybe users can change the values and paste those into the code etc?

What is your opinion or suggestion about this?
Reply
#2

(12-26-2024, 01:01 AM)4usol Wrote: Hello,

I would like to discuss how best to handle data that is used frequently in the project.
...
I would like to reduce the database call for this simple data, especially because it normally doesn't change or rarely changes.

I'm thinking about storing all of these values in the session, but I'm not sure if that will have a positive impact on server cache etc?

Another idea was to use local browser storage. At this point I'm worried for safety reasons. Maybe users can change the values and paste those into the code etc?

What is your opinion or suggestion about this?

What you're looking for is a server-side key-value cache, like Redis (now Valkey) or Memcached (older solution).

These solutions keep relational data in memory for much faster repeat access. They often improve application performance dramatically.

Your server must have one installed to use it; CodeIgniter supports them natively.

You should not store those things in the session or browser storage. You are correct it is likely to create a security issue.
Reply
#3

[quote pid="423478" dateline="1735200111"]

I would like to reduce the database call for this simple data, especially because it normally doesn't change or rarely changes.


https://github.com/tmarois/Filebase
[/quote]
Reply
#4

Use an in memory sqlite database that persists via the session.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB