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.
Store value outside the application
Hello Community
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?
Thanks, Alex
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 forhttps://our.umbraco.com/apidocs/v8/csharp/api/Umbraco.Core.Services.IKeyValueService.html
There isn't really any documentation besides the above reference documentation, but you can get an instance like:
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...