HP3000-L Archives

April 1999, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
John Korb <[log in to unmask]>
Reply To:
John Korb <[log in to unmask]>
Date:
Thu, 15 Apr 1999 11:32:10 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (109 lines)
How often is your system restarted?  The reason I ask is that the TIMER
intrinsic returns a 32 bit integer that is the count of milliseconds since
the midnight preceeding the last system start, but it is reset to zero
every 24 days as it would overflow during the 25th day.  If your system
runs for months on end without being restarted (or anything more than 24
days), then the logic is slightly more complicated, but still pretty easy.
Some of the advantages we found with the approach outlined below is that
the files are listed oldest file first (if your system is restarted once
every 24 or less days), not all files in the directory need be checked for
date/time, and the file name itself is a timestamp, eliminating the need to
call intrinsics like FLABELINFO.
<enhancement request plug>
In fact, IF there were a CI variable HPTIMER available, the whole cache
cleanup process could be handled in the CI.
</enhancement request plug>

If your program creates the files in the HFS space using the value returned
by TIMER as the file name, then deleting old files from the cache is pretty
simple.  LISTFILE,6 to a file, then call TIMER, subtract the number of
milliseconds you want to use as your maximum file age from the TIMER value,
then read the file created by the LISTFILE,6 and purge all files with a
name less than the value you calculated.  When you come to the first file
that has a name greater than the cut-off value, stop processing the
LISTFILE,6 file, and have the cache cleanup procedure go to sleep for a while.

Example.

It has been a couple of days since your system was last restarted.  Your
program calls TIMER and receives the value:

   188629271

which is 52 hours, 23 minutes, 49.271 seconds.

Your web program builds an HFS named file "188629271".  A few milliseconds
later it builds another file, again using the value from TIMER as the file
name, and the new file is named "188629544".  And over several minutes
dozens or perhaps hundreds of files are created.  They all have one thing
in common (provided that you restart your system at least once every 24
days) - the oldest files will appear first in the LISTFILE,6 output.

Now, your cache cleanup wakes up.  It calls timer and receives the value
"188778101", which is 52 hours, 26 minutes, 18.101 seconds.  It wants to
purge cache files that are more than 5 minutes old, so it subtracts 5
minutes (300,000 ms) from the value it received from TIMER (188778101)
yielding the value "188478101" (52 hours, 21 minutes, 18.101 seconds).  The
cleanup program does a LISTFILE,6 to a file, then opens the file and starts
reading the records (which contain HFS file names) from the file.  The
contents of the LISTFILE,6 file probably would look something like:

   WWW/PUB/cache/188545573
   WWW/PUB/cache/188629271
   WWW/PUB/cache/188629544
   WWW/PUB/cache/188721227
   WWW/PUB/cache/188763838

The cleanup program reads the first record, sees that the file name in that
record (188545573) is greater than its cut-off point (188478101), and goes
back to sleep.  The next time it wakes up, the TIMER value is "188898101",
and subtracting 5 minutes (300,000 ms) yields "188598101".  The cleanup
program does another LISTFILE,6 to a file, and when it reads the first
record finds that the first file name (188545573) is now less than the
value it calculated (188598101) so it PURGEs the file.  It reads the next
record from the LISTFILE,6 output file and finds that the file name
(188629271) is greater than its calculated cut-off value, so it goes back
to sleep.

Anyway, it works well for us, and assuming that all the cache files are in
a single directory, is easy to implement (no parsing, just chop off a fixed
number of characters from the start of each record in the LISTFILE,6 output
file).

Hope this helps.

John


At 4/15/99 09:51 AM , Mark Wilkinson wrote:
>I'm using FLABINFO to get the last-access date/time for a particular file
>with a
>view to
>finding out how old it is compared to the current date/time. If it's over a
>certain number of
>seconds or minutes old, then I want to purge it. (This is part of a web-based
>app that
>uses a lot of temp files as a kind of cache).
>
>I've looked for some intrinsic to manipulate and find differences between
>dates/times
>and can't find anything.
>
>Any pointers as to where I can find something that can do calculations
based on
>the
>date/time formats returned by FLABINFO (ie CALENDAR/CLOCK format)? Or maybe
>suggest ways of doing this more easily?
>
>TIA.
>
>Mark W.


--------------------------------------------------------------
John Korb                            email: [log in to unmask]
Innovative Software Solutions, Inc.

The thoughts, comments, and opinions expressed herein are mine
and do not reflect those of my employer(s), or anyone else.

ATOM RSS1 RSS2