Drag[en]gine Script Module DragonScript
1.23
|
Game usable cache directory. More...
Public Member Functions | |
Constructors | |
Cache | new (String directory) |
Create cache storing files into directory. More... | |
Management | |
FileReader | read (String id) |
Open cache file by identifier for reading if existing. More... | |
FileWriter | write (String id) |
Open cache file by identifier for writing. More... | |
void | delete (String id) |
Delete cache file by identifier if present. More... | |
void | deleteAll () |
Delete all cache files. More... | |
Game usable cache directory.
Stores files in game specific cache virtual file directory using a unique string identifier of variable length. The identifer can be any kind of string typically a file path or concatenations of file path and other information. While opening or saving a file a file reader/writer is returned with the file pointer set to the starting position of the cache content.
Cache content is persistent across game launches but not across different machines. The user decides how much disk space is allowed to be used by game caches. If new files are written while space becomes low the oldest files will be deleted to make space to store the new file. This means the game should not try to store huge amount of cache data or caches are constantly rebuild.
The user of the cache is responsible to write into the cache content any data required to detect outdated cache content. If content is outdated use delete() call to delete the cache file.
Multiple caches can be used to group types of cached files as long as they all have different cache directories.
The typical usage looks like this.
This is a native class.
void Dragengine.Cache.delete | ( | String | id | ) |
Delete cache file by identifier if present.
void Dragengine.Cache.deleteAll | ( | ) |
Delete all cache files.
Cache Dragengine.Cache.new | ( | String | directory | ) |
Create cache storing files into directory.
Directory is located under the game cache directory. Each cache has to use a unique directory.
EInvalidParam | Cache directory already in use. |
FileReader Dragengine.Cache.read | ( | String | id | ) |
Open cache file by identifier for reading if existing.
FileWriter Dragengine.Cache.write | ( | String | id | ) |
Open cache file by identifier for writing.