Expand description
What was fetched from the web, kept on disk so that it is not fetched again at every start.
A DiskCache is a directory of files, one for each thing kept,
named by the hash of what it is kept as: its address, and which form
of it this is. Nothing in a name says whose picture it is. What is
kept, and how it is written, is its ownerβs to say (see
crate::images, which keeps avatars); this is where it is put, how
long it counts as fresh, and what goes when there is too much.
A file is fresh for a while after it was written. Past that it is still there, but stale: its owner asks the web again, and falls back on it if nobody answers. So what changed at the same address is seen within that while, and what is on disk still shows with no network.
What is used is written anew as it goes stale, so a file that has
grown old was not asked for in a long time. Those go at the start of a
run (see DiskCache::sweep), and after them the oldest, for as long
as the directory holds more than it may.
It is a cache: losing any of it costs a fetch. A file that cannot be written is not kept, one that cannot be read was not there, and neither is said to anyone but the journal.
StructsΒ§
- Disk
Cache - A directory of things fetched, kept by what they are (see the module).
- Kept
- What was kept of something, and whether it still counts as what is there.
ConstantsΒ§
- FRESH_
FOR π - How long what is kept counts as what is there now.
- KEPT_
FOR π - How long what is kept stays without being written anew: what is older was not asked for since it went stale.
- MAX_
BYTES π - How many bytes the files kept may take, all together.
- UNFINISHED π
- What a file that is being written ends in, until it is whole.