Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I need to store some variables outside of the application lifecycle. So when application restarted I need to be able to access the value. This is actually just a number so I don't want to use a database.
Does Umbraco have something to store such kind of data?
I know that I can store on the IIS level or file, but still, maybe some helper available?
This sounds like a scenario in which you could use IKeyValueService. It does save a row in the database, but otherwise it might be the "helper" you're looking for
There isn't really any documentation besides the above reference documentation, but you can get an instance like:
IKeyValueService kv = Current.Factory.GetInstance<IKeyValueService>();
// Retrieve the "Hello" key from the database
string value = kv.GetValue("Hello");
// Set a value for the "Hello" key in the database
kv.SetValue("Hello", "Some value");
I don't know your specific use case, but having this in the database would generally be considered safer than having it in a file on disk.
Anders, thank you so much!!! I owe you a beer :) hopefully, next Codegarden!!!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted