-
Notifications
You must be signed in to change notification settings - Fork 6
Cache System
Did you ever notice the RM_Cache.json file in your map directory? This file serves to preserve custom data between runs of the script. More specifically, it's used to prevent intensive data from being generated multiple times across multiple runs of a script.
It's particularly useful for Model Scene, as it allows you to skip processing the sometimes hefty animations every single run for each model, given that the model file hasn't changed.
To use the cache, simply call the rm.cacheData function. It has three parameters:
-
name- This will be the "key" of the data in the JSON file. Just name it something unique. -
process- This is the function that will be generating the data we want to store. It must be asynchronous, as we could be using it for grabbing things from disk. -
hash- This string should be unique to the data you generated. If the hash in the JSON file doesn't match the hash you pass in the function,processwill be called to regenerate the data.
const myValue = 4
async function generateMyData() {
return myValue * 2
}
const myData = await rm.cacheData('My Data', generateMyData, `${myValue}`)Let's pretend that generateMyData created a huge amount of data that takes a while to process. In this example, myValue seeds the data we want to generate. As long as myValue doesn't change the next time we run the script, it will generate the same data, so we can save some time by just grabbing it again. If it does change, we can re-generate the data.
This is exactly what cacheData does. It compares the seed you pass in the current run with the seed from the stored data, and if they don't match, the data is regenerated and stored in the file with the new seed. Otherwise, the existing data is passed to you.
It's also important to note that data which isn't accessed during a run will be discarded. This is to prevent "dead" data from staying in the file.
- Info
- Difficulty
- Beatmap Objects
- Gameplay Objects
- Walls
- Basic Notemods
- Note Iterators
- Basic Events
- V3 Events
- Custom Events
- Heck Tracks and Animation
- Easings
- Point Types
- Point Utilities
- Heck Animation Baking
- Heck Animation Settings
Non-Vivify Models
Vivify