;******************************** ;* ;* lcmf_main.pbi ;* ;* (c) Cache (m) Memory and (f) File ;* ;* LiHaSo Webserver Modul In Memory File Cache ;* ;* It Could be configured Globaly and by Virtualhost ;* DeclareModule lcmf #Cache_Server_Single = 0 #Cache_Server_Multi = 1 EnumerationBinary lcmf_init #Mem_Cache #File_Cache EndEnumeration EnumerationBinary lcmf_object_state #NA ;Not available #InProgress ;Copy is in Progress #Cached ;Object is available #Cleaning ;Object is on the way to cleaned out EndEnumeration EnumerationBinary lcmf_params_state ;#UCP = Universal Cache Params (File and Mem) #UCP_Max_Size_Total ;Total Size of Cache #UCP_Max_Size_per_Entry ;Max Size of a File or Memoryblock ;#FAC = File Access Config #FAC_MC ;Minimum Access Times until a File is Cached (Generic) #FAC_RT ;Max Time a File could be in Cache (Generic) #FAC_LA_RT ;How long a File could stay in Cache sinde last Access (Generic) ;(If a File has regulary access For ex. every 10 min. And this lifetime is 3600min. it will be killed after FAC_RT is reached) #FAC_WL_Add ;Whitelist add Generic (Ex. : ;".html" = All html files ;"file.html" Expliciz Filenames ;"/path/" Including all Files and Subdirectorys It is added to Valid_Source ;"/path" only Files in Directory ;"'/path/','.rpm'" Combines a path and a Specific file extension #FAC_WL_Add_Ext ;Whitelist which add with special MC/RT/LA_RT Params #FAC_Valid_Source ;From where the files could get #FAC_Cache_Dir ;Directory where the Cached Files could be written ;Some Function for Set_State who do a active Work #FAC_Check_Cache ;Checks if all Files are the Same as Source #UCP_Flush_Object ;Removes a Object from Cache EndEnumeration Declare.s Init(Server_Type.i = #Cache_Server_Multi) ;Create a Main Cache_Thread Management Server Declare.s Init_cache(Cache_Type.i = #Mem_Cache) ;Create a Cache_Thread gives back the UUID Declare.i Set_Params(Server_ID.s, Parameters.s) ;Set Cache Parameters in pre run state Declare.i Use_New_Params(Server_ID.s) ;Reinit the Cache Thread Declare.i Run_Cache(Server_ID.s) ;Start a initialised Cache Init()->InitCache()->Set_Params()->Run_Cache() Declare.i Kill_Cache(Server_ID.s) ;Kills a Cache Server Thread Declare.i Set_State(Server_ID.s, Parameters.s) ;Force to do something in Cache Thread (Flush a Element, Cleanup the Filecache-IO Intesitive, Check for Updates on Files an co.) Declare.s Get_State(Server_ID.s, Parameters.s) ;Get Cache Server Thread State (For ex. current elements cachced, sizes and co.) Declare.s Put_Mem(Server_ID.s, Memblock_ToSave.i, MC.i=-1, RT.i=-1, LA_RT.i=-1) ;Push a Memory Block to cache (Ex. some pre executed scripts or pictures and so on.) Declare.s Get_Mem(Server_ID.s, Memblock_ID.s, MC.i=-1, RT.i=-1, LA_RT.i=-1) ;Get That Memoryblock from cache who was Previously Stored Declare.s Get_File(Server_ID.s, Full_File_Name.s, Force_Disk.i = #True) ;Get a File (Cached or uncached) could be used everytime (ServerUUID empty everytime uncached or Flag uncached is set) EndDeclareModule Module lcmf IncludeFile "lhs_uuid.pbi" Structure lcmf_mem_objects MemoryAddress.i State.i EndStructure Structure lcmf_file_objects LocalFileUUID.s EndStructure Structure lcmf_cache_servers EndStructure Structure lcmf_cache_servers_config_prepare EndStructure Procedure.i Main_Thread(ID.i) ;What this Thread does: ;* Check if Subthreads are alive and if not remove from Mapping Space ;* Spawn new Cache Threads and Kill Cache Threads EndProcedure Procedure.i Cache_Mem_Thread(ID.i) ;What this Thread does: ;* Manage the mem Objects EndProcedure Procedure.i Cache_File_Thread(ID.i) ;What this Thread does: ;* Manage the file Objects and maybe the memobjects. EndProcedure Procedure.i Copy_Thread(ID.i) ;What this Thread does: ;* Copy a File to Cachefolder EndProcedure Procedure.i Check_Thread(ID.i) ;What this Thread does: ;* Checks the Cachefolder and Memorymap if all Files are valid. EndProcedure Procedure.i Copy_File_to_Memory_Thread(ID.i) ;What this thread does: ;* Copy a local cached File to Memory ; EndProcedure EndModule