Added temp hotcache to fix the pooling issue

This commit is contained in:
2025-09-07 21:39:31 +08:00
parent 97e0479181
commit dd9a204c08

20
api.js
View File

@@ -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 );
}
} );
};