
<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<%
response.Charset="GBK"
class AppCache

	Public icachetime,icacheid
	Private v_cacheName,cachedata 

	Private Sub Class_Initialize() 
		icachetime=clng(app_cachetime) 
		icacheid= app_cacheid
	End Sub 
	
' 清除缓存
Public function clscache()
	Application.Lock()
	Application.Contents.RemoveAll()
	Application.UnLock()
end function

' 设置缓存
Public function setcache(byval cachename,byval cachevalue)
	dim cachedata
	cachename = lcase(cachename)
	cachedata = application(icacheid & cachename)
	if isarray(cachedata) then
		cachedata(0) = Cachevalue
		cachedata(1) = now()
	else
		Redim cachedata(2)
		cachedata(0) = Cachevalue
		cachedata(1) = now()
	end if
	application.lock
	application(icacheid & cachename) = cachedata
	application.unlock
end function

' 获取缓存
Public function getcache(byval cachename)
	dim cachedata
	cachename = lcase(cachename)
	cachedata = application(icacheid & cachename)
	if isarray(cachedata) then getcache = cachedata(0) else getcache = ""
end function

' 检测缓存
Public function chkcache(byval cachename)
	dim cachedata
	chkcache = false
	cachename = lcase(cachename)
	cachedata = application(icacheid & cachename)
	if not isarray(cachedata) then exit function
	if not IsDate(cachedata(1)) then exit function
	if DateDiff("s", CDate(cachedata(1)), now()) < 60 * app_cachetime then chkcache = true
end function

'读取文件缓存,如果没有则创建
Function loadFileOnCache(Byval fileFlag,Byval filePath)
	dim cacheName
	cacheName=fileFlag & filePath
	if app_cache = 1 then
		if (CacheOBJ.chkCache(cacheName)) then  
		loadFileOnCache = CacheOBJ.getCache(cacheName) 
		else 
		loadFileOnCache = FSOOBJ.FSOFileRead(filePath)
		CacheOBJ.setCache cacheName,loadFileOnCache
		end if
	else
		loadFileOnCache = FSOOBJ.FSOFileRead(filePath)
	end if
End Function

Function loadTypePathOnCache(typeId)
	dim cacheName,pathStr
	cacheName="type_path"&typeId
	if app_cache=1 and  CacheOBJ.chkCache(cacheName)  then  
		pathStr = CacheOBJ.getCache(cacheName)
	else
		pathStr = getDicName("tbl_type","t_enname","t_id",typeId)
		CacheOBJ.setCache cacheName,pathStr
	end if
	loadTypePathOnCache=pathStr
End Function

end class
%>