PageCache except check
This commit is contained in:
parent
96c9d608c2
commit
16618e5165
@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
var cl = global.botanLoader;
|
||||
var Dragonfly = global.Dragonfly;
|
||||
const cl = global.botanLoader;
|
||||
const Dragonfly = global.Dragonfly;
|
||||
|
||||
var Cookie = cl.load( "botanss.net.components.Cookie" );
|
||||
const Cookie = cl.load( "botanss.net.components.Cookie" );
|
||||
|
||||
class CResponse
|
||||
{
|
||||
@ -22,7 +22,6 @@ class CResponse
|
||||
this.cookie = new Cookie( "", Http );
|
||||
}
|
||||
|
||||
|
||||
end()
|
||||
{
|
||||
if( this.canExit )
|
||||
|
@ -16,6 +16,7 @@ class WebFrame
|
||||
this.HTTP = Http;
|
||||
this.result = 0;
|
||||
this.planted = false;
|
||||
this.allowCache = true;
|
||||
this.requestStr = "";
|
||||
this.requestObj = {};
|
||||
|
||||
@ -138,7 +139,7 @@ class WebFrame
|
||||
|
||||
__storeCache( cache, ttl )
|
||||
{
|
||||
if( cache && PageCache )
|
||||
if( this.allowCache && cache && PageCache )
|
||||
{
|
||||
if( ttl == undefined ) ttl = 30;
|
||||
PageCache.store(
|
||||
|
@ -3,11 +3,15 @@
|
||||
const Dragonfly = global.Dragonfly;
|
||||
const cl = global.botanLoader;
|
||||
|
||||
const Cookie = cl.load( "botanss.net.components.Cookie" );
|
||||
|
||||
class PageCache
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.cache = { };
|
||||
this.cache = {};
|
||||
this.excepts = {};
|
||||
|
||||
setInterval( () => {
|
||||
var d = new Date().getTime();
|
||||
for( var i in this.cache )
|
||||
@ -15,6 +19,12 @@ class PageCache
|
||||
var c = this.cache[ i ];
|
||||
if( c.ttl < d ) delete this.cache[ i ];
|
||||
}
|
||||
|
||||
for( var i in this.excepts )
|
||||
{
|
||||
var c = this.excepts[ i ];
|
||||
if( c.ttl < d ) delete this.excepts[ i ];
|
||||
}
|
||||
}, 30000 );
|
||||
}
|
||||
|
||||
@ -38,8 +48,22 @@ class PageCache
|
||||
Dragonfly.Debug( "StoreCache: \"" + key + "\", expire " + new Date( expires ) );
|
||||
}
|
||||
|
||||
except( sid, ttl )
|
||||
{
|
||||
if( !global.pagecache ) return;
|
||||
|
||||
var expires = new Date().getTime() + 1000 * ttl;
|
||||
|
||||
this.excepts[ sid ] = { ttl: expires };
|
||||
|
||||
Dragonfly.Debug( "CacheExcept: \"" + sid.substr( 0, 8 ) + "\", expire " + new Date( expires ) );
|
||||
}
|
||||
|
||||
process( req, res )
|
||||
{
|
||||
var cookie = new Cookie( req.headers.cookie );
|
||||
if( cookie.get( "sid" ) in this.excepts ) return false;
|
||||
|
||||
var url = req.url;
|
||||
if( url in this.cache )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user