Do you mean the tree self-destructs nodes and I will be notified of it to delete? Or is it optional? Basically here is my destruction function:
bool __fastcall ProxyCache::deleteFileFromRAMCacheWRTIndex(RAMFileCache *bufferFileCache, bool alreadyMarkedAsToDelete) { if(!bufferFileCache) return false; if(bufferFileCache->cacheTreeNode) { RAMFileCacheIndex->Remove(bufferFileCache->cacheTreeNode); bufferFileCache->cacheTreeNode = NULL; } cacheCurrentRAMSize -= bufferFileCache->getAndZeroSize(); // first time it subtracts and then returns 0 if(!bufferFileCache->getWriteLock() && !bufferFileCache->getIsReadLock()) { delete bufferFileCache; return true; } else { if(!alreadyMarkedAsToDelete) bufferFileCache->setDeleteFileASAP(); return false; } } //-------------------------------------------------------------------------- IOW, in our cache one URL can have just one entry in the tree but many sockets can be pending to delete. It has to wait until the very last socket connection to delete the actual object. Best Regards, SubZ On Sun, Dec 4, 2011 at 11:40, Arno Garrels <arno.garr...@gmx.de> wrote: > Fastream Technologies wrote: > > What about the events? Do I need to use them in TCacheTree? > > Thanks a lot, > > Most important is of course OnFreeData that triggers whenever > an entry is removed, so simply free Data there if required. > > Traversing the tree is only possible with method ListTree > and assigning an OnList event handler. > > -- > Arno Garrels > > > > > SZ > > On Sun, Dec 4, 2011 at 11:05, Arno Garrels <arno.garr...@gmx.de> > > wrote: > > > >> ----- Original Message ----- > >> From: "Fastream Technologies" <ga...@fastream.com> > >> To: "ICS support mailing" <twsocket@elists.org> > >> Sent: Sunday, December 04, 2011 7:16 AM > >> Subject: Re: [twsocket] Converting a cache to AVL tree > >> > >> > >>> The component I tried to use is TCacheTree. It has a timeout > >>> argument for each added item. I do not want any timers or any > >>> timeouts yet liked the component. Is there a way to omit > >>> expiration. I will use my own code for it. > >> > >> TCacheTree doesn't use any timer, it just provides two TDateTime > >> fields. There are two indices, first is Key of type string, second > >> is TimeStamp of type TDateTime used to find oldest entries very > >> fast. It's two linked AVL trees. > >> > >> procedure Insert( > >> Key : String; // Unique key > >> Data : Pointer; // Pointer to data > >> Len : Integer; // Optionally data size > >> TimeStamp : TDateTime = MinDT; // Second key (dups are allowed > >> and handled) > >> Expires : TDateTime = MinDT; // What ever you like > >> UpdateTime : Boolean = True; // Shall the TDateTime fields be > >> updated? > >> UpdateData : Boolean = True); // Shall Data be updated? > >> > >> Use Insert() for both add and update an entry. > >> > >> Node : TCacheNode; > >> begin > >> Node := FCacheTree.FindKey(Key); > >> if Node <> nil then > >> begin > >> // Node.IdxRef.TimeStamp // i.e read the TimeStamp > >> // i.e update TimeStamp and Expires, don't update Data > >> FCacheTree.Insert(Key, nil, 0, time1, time2, TRUE, FALSE); > >> end; > >> > >> Oldest() returns oldest entry. > >> Flush() removes all entries older or same DateTime as passed. > >> > >> Hope this helps. > >> > >> -- > >> Arno Garrels > >> > >> > >>> Best Regards, > >>> > >>> SZ > >>> On Sat, Dec 3, 2011 at 18:54, Arno Garrels <arno.garr...@gmx.de> > >>> wrote: > >>> > >>>> Fastream Technologies wrote: > >>>>> Hello, > >>>>> > >>>>> I wonder if there is an easy way to do this? How does one achieve > >>>>> no timeout in ICS avl tree? > >>>> > >>>> Please be more specific, AFAIR there's no timeout in any ICS AVL > >>>> tree. BTW: Also have a look at the new TIcsAvlPointerTree and > >>>> TIcsAvlObjectTree in the IPv6 branch, included in > >>>> OverbyteIcsAvlTrees. > >>>> > >>>> -- > >>>> Arno Garrels > >>>> -- > >>>> To unsubscribe or change your settings for TWSocket mailing list > >>>> please goto > >>>> http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit > >>>> our website at http://www.overbyte.be > >>>> > >>> -- > >>> To unsubscribe or change your settings for TWSocket mailing list > >>> please goto > >>> http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our > >>> website at http://www.overbyte.be > >> -- > >> To unsubscribe or change your settings for TWSocket mailing list > >> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket > >> Visit our website at http://www.overbyte.be > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be