Ok but how will I update an existing duplicarte record so that it becomes Last()?? Best Regards,
SZ On Mon, Dec 5, 2011 at 13:11, Arno Garrels <arno.garr...@gmx.de> wrote: > Fastream Technologies wrote: > > 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 > >> > >> > >> > > > > Critical question: Node.IdxRef.TimeStamp = updatedDate; > > You can't assign a value, property TimeStamp is read-only. > > > Would this work? Because we may have duplicates... > > Use Insert() as described above to update the TimeStamp value. > Yes, TimeStamp duplicates are allowed. > > -- > Arno Garrels > > > > > > Regards, > > > > SZ > -- > 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