✅ AppContext in web api project
Team, Do we have something like appcontext in .net core web api project where we store all the frequently used objects and all the users need to access the objects(application scope). (To reduce the call to db)
47 Replies
You mean a cache?
Dependency injection?
User claims?
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Yes , should I go for Redis then? @ZZZZZZZZZZZZZZZZZZZZZZZZZ @TeBeClone
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
One example is some common settings data, I will hit the db once and store in the app scope so every user can access it..
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
the entire app
not users
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
not frequently
backend data
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Once when we deploy ...not in the middle as of now..
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
yes appsettings is one option..
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
appsettings.json:
src/Foo/FooOptions.cs:
src/Foo/FooServiceCollectionExtensions.cs:
Program.cs / Startup.cs:
Bar.cs:
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
But only few settings are fixed like I said above, which can go for config file... I want some more configurable data as well ...which may get changed ocassionally... so thought of db ...
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
IIS
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Inside our own VM
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Yes going through it
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
OK got it
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Should I install Redis as a seperate thing?
How to deploy ?
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Yes
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
I just use a singleton synchronized with a JSON file ¯\_(ツ)_/¯
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Well, you can change the value in the singleton live
And then save the changes to a file
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Ah, well, sure you can persist it in a db
Can't see why, but yeah
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
I'll take your word for it, since I never had to work with IIS
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
dis advantage means performance wise ?
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Never had any issues ¯\_(ツ)_/¯
Settings are always in memory, in the singleton, and should I need to restart the app they're also persisted in a file
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Yes
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Got it ...
Thanks for the detailed explaination.... learnt many things from your conversation @TeBeClone @ZZZZZZZZZZZZZZZZZZZZZZZZZ
For reference, I just have this class injected as a singleton and it works really well so far: https://paste.mod.gg/ikmjgdrhahtu/0
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.