Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
for 1.3.4 Enable TTL Cache
(function(){
var before = Date.now();
var TTL_SEC = 5.0;
var Scene_Base_prototype_terminate = Scene_Base.prototype.terminate;
Scene_Base.prototype.terminate = function (){
var current = Date.now();
SceneManager.updateManagers(1, (current - before));
before = current;
return Scene_Base_prototype_terminate.call(this);
};
ImageManager.cache._lastRemovedEntries = [];
var ImageManager_loadSystem = ImageManager.loadSystem;
ImageManager.loadSystem = function(filename, hue){
var bitmap = ImageManager_loadSystem.call(this, filename, hue);
bitmap.__system = true;
return bitmap;
};
var CacheEntry_prototype_isStillAlive = CacheEntry.prototype.isStillAlive;
CacheEntry.prototype.isStillAlive = function () {
return CacheEntry_prototype_isStillAlive.call(this) || this.item.__system;
};
CacheMap.prototype.setItem = function (key, item) {
var entry = new CacheEntry(this, key, item);
entry.setTimeToLive(0, TTL_SEC * 1000);
return entry.allocate();
};
var Graphics_createRenderer = Graphics._createRenderer;
Graphics._createRenderer = function(){
Graphics_createRenderer.call(this);
this._renderer.textureGC.maxIdle = TTL_SEC * 60;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment