Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As you probably found, there are a variety of ways that you can do this, ranging from Microsoft-recommended to 100% roll-your-own. You're currently on the roll-your-own end of the spectrum, which I think is usually better anyway.</p> <p>Anyway, basically what you're looking for is a StateBag. Something loosely typed and highly configurable, which doesn't really lend itself very well to an RDBMS, but if you already have the SQL Server in place, it's probably going to be easiest to just use that.</p> <h2>Option 1: Redis</h2> <p>However, another option is to run something like Redis for site configurations. You can store it as a collection of key/value pairs in a Redis object, pull it in a JSON object, and then either convert that to a Hashtable, where lookups will be very fast, or some other hashable collection. A simple wrapper class around the collection would suffice.</p> <p>Redis is very light and in your case wouldn't require a lot of configuration or maintenance.</p> <h2>Option 2: SQL Server</h2> <p>The way you've mentioned is actually a pretty good way of doing it, but rather than query the database every time, put a strongly typed collection or Hashtable in the cache and let it expire every few hours.</p> <p>If you go with essentially what you have now, you could store it like this:</p> <pre><code>Setting SettingId Int PK, Key NVarchar(50), Name NVarchar(50), Description NVarchar(1000), Type NVarchar(50), Priority Int Configuration SiteId Int, SettingId Int FK(Setting), SettingValue NVarchar(1000) </code></pre> <p>Don't store things like live/test/dev in the database. You need to have completely separate databases and servers to distinguish between live/test/dev/stage/QA etc.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload