Improving performance
Caching stores data in memory. This allows you to read and write multiple keys at once, significantly improving performance when files contain many keys.
Creating a file in the cache
You can create a file in cache by simply setting the storage location to ES3.Location.Cache:
1 2 3 4 5 6 7 8 9 10 |
// Create an ES3Settings to save to and load from the cache. var settings = new ES3Settings(ES3.Location.Cache); // Save to the cached file. ES3.Save("myInt", 123, settings); ES3.Save("myTransform", this.transform, settings); // Load from the cached file. var myInt = ES3.Load("myInt", 0, settings); ES3.LoadInto("myTransform", this.transform, settings); |
Storing a cached file to a local file
You can store a file in the cache to a permanent local file using ES3.StoreCachedFile.
1 2 |
// Store the default cached file to a permanent local file. ES3.StoreCachedFile(); |
Loading an existing file into the cache
You can load an existing file into the cache using ES3.CacheFile. You can then read data from this cached file by settings the storage location to cache:
1 2 3 4 5 6 7 8 9 |
// Cache a local file and load from it. ES3.CacheFile("MyFile.es3"); // Create an ES3Settings to load from cache. var settings = new ES3Settings("MyFile.es3", ES3.Location.Cache); // Load from the cached file. var myInt = ES3.Load("myInt", 0, settings); ES3.LoadInto("myTransform", this.transform, settings); |