From dd9a204c08910c78d7a6648c28a1e1a2105ad1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Sun, 7 Sep 2025 21:39:31 +0800 Subject: [PATCH] Added temp hotcache to fix the pooling issue --- api.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/api.js b/api.js index f06d200..7a473af 100644 --- a/api.js +++ b/api.js @@ -11,6 +11,8 @@ var conf = cl.load( "config.all" ).botanjs; var hash = cl.load( "botansx.utils.hash" ); var rand = cl.load( "botansx.utils.random" ); +var HOT_CACHE = {}; + var BotanJS = function() { events.EventEmitter.call( this ); @@ -89,6 +91,8 @@ BotanJS.prototype.compile = function( type ) var rainet = conf.rinet || conf.serviceUri; + var hotCache = HOT_CACHE[ type ] = HOT_CACHE[ type ] || {}; + if( conf.type && "or".indexOf( conf.type ) != -1 ) { this[ type ] = rainet + conf.type + type + "/" + resList.join( "/" ); @@ -102,8 +106,16 @@ BotanJS.prototype.compile = function( type ) }; - var q = resList.sort().join( "," ); - var lookupKey = hash.md5( q ); + var resQuery = resList.sort().join( "," ); + var lookupKey = hash.md5( resQuery ); + + if( hotCache[ lookupKey ] ) + { + Dragonfly.Debug( "HOT_CACHE: " + lookupKey ); + _self.storeForRender( rainet, type, hotCache[ lookupKey ] ); + _self.emit( "complete" ); + return; + } var Session = cl.load( "botansx.modular.session" ); var fastCache = new Session( lookupKey, "BOTAN_JCACHE", true ); @@ -130,6 +142,8 @@ BotanJS.prototype.compile = function( type ) { _self.storeForRender( rainet, type, ch ); + hotCache[ lookupKey ] = ch; + Dragonfly.Debug( "Storing " + _trim( ch ) + " to fastcache[ " + fastCache.id + " ]" ); fastCache.spawn( 86400 ); @@ -161,7 +175,7 @@ BotanJS.prototype.compile = function( type ) } else { - zlib.deflate( q, deflateComplete ); + zlib.deflate( resQuery, deflateComplete ); } } ); };