Caching

Caching improves performance by storing data in RAM rather than directly to permanent storage. This allows you to combine multiple reads and writes into a single call, significantly improving performance when files contain many keys.

You can enable caching by changing the Location to Cache in Tools > Easy Save 3 > Settings.

This will automatically load the default file (i.e. the file defined by the Default File Path in Settings) into the cache when your application starts. You can change this using the Auto cache default file setting.

It will also automatically store any dirty cached files to permanent storage at the end of every frame. You can change this using the Store cached data setting.

You can alternatively use an ES3Settings object to set the Storage Location to ES3.Location.Cache for a specific ES3 method call, but you would need to manually cache and store the file yourself as described in the sections below.

When the storage location is set to Cache, your save calls will automatically save to the cache rather than permanent storage, so the way you use ES3.Save does not change.

When the storage location is set to Cache, your load calls will automatically load from the cache rather than permanent storage, so the way you use ES3.Load does not change.

Note that you can’t load from a file which doesn’t exist in the cache. If you have set the Location to Cache in the Settings window then Easy Save will automatically load your file into the cache.

If you are using an ES3Settings object to set the location to the Cache, or are saving to files other than the default file, you will need to use ES3.CacheFile to load the file into the cache before loading from it as described in the next section.

You can load an existing file from permanent storage into the cache using ES3.CacheFile:

The ES3.CacheFile method can also accept a filePath or an ES3Settings object if you wish to cache a specific file rather than the default file:

You might need to manually tell Easy Save to store a file in the Cache to permanent storage, for example if you are using an ES3Settings object to enable caching rather than setting it in the default settings.

You can do this using ES3.StoreCachedFile.