|
Drag[en]gine Script Module DragonScript 1.35
|
Game usable cache directory. More...
Public Member Functions | |
Constructors | |
| Cache | new (String directory) |
| Create cache storing files into directory. | |
Management | |
| FileReader | read (String id) |
| Open cache file by identifier for reading if existing. | |
| FileWriter | write (String id) |
| Open cache file by identifier for writing. | |
| void | delete (String id) |
| Delete cache file by identifier if present. | |
| void | deleteAll () |
| Delete all cache files. | |
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 | ) |
| void Dragengine.Cache.deleteAll | ( | ) |
| Cache Dragengine.Cache.new | ( | String | directory | ) |
| FileReader Dragengine.Cache.read | ( | String | id | ) |
| FileWriter Dragengine.Cache.write | ( | String | id | ) |
Open cache file by identifier for writing.
Referenced by delete().