Welcome Guest, Not a member yet? Register   Sign In
Transient support for Settings
#1

Sorry if this has been covered elsewhere or by other features.

It'd be nice if settings could accept a TTL parameter. Not sure how the best way would be to pass it, but the idea is that a setting can be temporary, a transient.

Expired transients can be removed by CI at any time, and/or by something like service('settings')->forgetTransients() maybe.

So I'd do service('settings')->set('User.Reminder', 'SomeValue', 'SomeContext', 3600) for the setting to live for 3600 seconds.

If I do a service('settings')->get() for this within 3600 seconds, the value is returned, otherwise whatever get() normally returns on a "not found" request is returned.

This is much like WordPress' transients.

I understand this could, probably, be implemented using CI caching, but my point is related to "settings" / "config" only, and temporary values.

-joho
Reply
#2

Config classes are essentially have system settings and they are static values.
See https://codeigniter4.github.io/CodeIgnit...on-classes

The use case for temporary values is not clear to me.

In my opinion, "Contextual Settings" feature is not a good feature.
Of course, things like user settings exist, so there is the issue of how to handle them.
But treating system settings and user settings as the same "Config" is confusing.
Reply
#3

The use case range from settings that are related to a given window of time. Basically, I guess you could say that a setting with no TTL is a permanent setting, whereas a setting with a TTL value is a temporary setting. Transients can be used to create "timers" or "events" that outlast a session, to send reminders, to revert a temporary setting, whatever ...

I definitely agree about the "Contextual settings". Perhaps "User settings" belong in the Auth section of the library.

-joho
Reply
#4

Probably you can write a helper function that uses Cache and Settings.
If there is cache, return it. If not, get the value from setting().
If you *override* the setting() function, you can get what you need soon.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB