Score:0

How do I set the expiration value for tempstore.private service?

cn flag

I am using the tempstore.private service, which uses an expiration time of one week. I need to change this; changing it globally is fine.

There is an $expire property, but I've no idea how I'm supposed to set it.

Score:2
fr flag

The expiration time is a parameter set in the service container. If you look at core/core.services.yml you will see the tempstore.expire parameter is set with a default value of 604800 seconds. This value is set when the container is compiled, and will be the same for all private tempstores.

There doesn't seem to be a way to set this in code or to override the parameter with a configuration setting, although I do see some issues in the core issue queue for adding that ability.

So apart from editing core.services.yml, you can override the tempstore.private service in your own module in order to customize the behavior.

thiokol avatar
cn flag
Thank you, its not ideal but setting it in core.services.yml will be sufficient for me.
4uk4 avatar
cn flag
@thiokol, don't edit core.services.yml. Site-specific you can add the parameter to services.yml parallel to settings.php. Modules can add the parameter to mymodule.services.yml. Then it will be compiled into the container when you clear the cache.
fr flag
Yes, services.yml is the right way to go. I didn't know about that.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.