Storeless

The Storeless module inherits from TotalCache and so is described more in the Total Caches page.  This module will hold all Lynicon data (or some) in memory, with a JSON file based backup for persisting this data through web server shutdowns. This is highly efficient and saves costs as it can remove the need for a database to be used with the CMS. For large sites the cost in memory may become to great and the time taken to save the file too long, however it should work well up to several thousand content items.

Configuring the Storeless module

Add one of the following lines of code to Startup.cs, immediately following .UseModule<CoreModule>().

Generally the first line would be used. The second line can be used to set up Storeless for only certain content types. 

.UseModule<Storeless>(Configuration.GetSection("Lynicon:Storeless:Cache"))

.UseModule<Storeless>(Configuration.GetSection("Lynicon:Storeless:Cache"), (Func<Type, bool>)(t => !(new Type[] { typeof(User) }.Contains(t))))

Sample configuration section e.g. in appsettings.json:

"Lynicon": {
    ... ,
    "Storeless": {
      "Cache": {
        "CacheReporting":  true,
		"SaveAlways": false,
		"SaveInterval": 4
      }
    }
  }


The 3 values above have the following effects:

  • CacheReporting if set to true will when the module loads data from the file, output to the log a comparison of the loaded data with the data currently in memory if there is any.
  • SaveAlways (default = true) will case the in memory cache to be saved to the file every time a change is made to it. This is done asynchronously so does not prolong the save process.
  • SaveInterval (default = 0) will if non-zero set up a background process that save the in memory cache to the file every n minutes where n is the value given.

The Storeless module has the following arguments when set up:

  • An IConfigurationSection pointing to a configuration section: an example configuration is shown, currently this simply sets whether to use CacheReporting or not which outputs to the log file cache issues.
  • Optionally, it can have the ApplyToType property set which is a function from Type to bool where the type is a container type and the result is true if this container type is held in memory. Any container types excluded here will require some other kind of persistence to be set up.

Initial Setup for First Use

When the Storeless module is first configured, there will be no dump file in existence and therefore the CMS will have no data.  If you are using Storeless to remove the need for a database, this will include there being no users set up.  Therefore you need to run the Initialize-Admin command (see the setup instructions) which will create an admin user and save this data to the JSON dump file.  When you start the CMS after this you will be able to log in as the admin user and start creating data.

Saving data while developing

While full IIS will trigger saving of data to the dump file when gracefully shut down, IIS Express will not do this and neither will stopping the web server via the debugger. To ensure your latest data is saved, go to /Lynicon/Admin and click the Save To File button on the row for the Storeless module. This immediately writes the in memory data to the JSON dump file (which can be found in /wwwroot/data/Storeless.json). When the CMS is next started, it will read in the saved state of the data.