af_cache(3)
π af_cache(3) β AtFS derived object cache handling π
ok so bestie, welcome to af_cache(3), straight out of the Attribute Filesystem (AtFS) era, and it's giving old-school but iconic. This page covers two little functions that team up to handle derived object caches: af_savecache and af_cachesize. Let's get into it π«Ά
β¨ SYNOPSIS β¨
#include <atfs.h>
int af_savecache (Af_key *busyAso, Af_key* cachedAso, char *attr, int
mode)
int af_cachesize (char path, int totalMax, int maxPerName, int
maxPerGivenAttr);
πΈ DESCRIPTION πΈ
af_savecache πΎ
Okay so af_savecache takes a busy attributed software object β that's your busyAso β and copies it into a derived object cache. The key for the resulting cached ASO gets handed back to you in the cachedAso buffer. Slay. β¨
Now here's the thing, and it's lowkey important: derived object caches are meant to hold derived objects that you can reproduce at any time. Why does reproducibility matter so much? Because cached ASOs may get deleted automatically when the derived object cache runs out of storage. π So like, don't put anything precious in there that you can't rebuild, bestie.
A cache allows a certain number of versions per name to hang out β that's controlled by the function af_cachesize, which we'll get to in a sec. Once that number is reached, every time a brand new version shows up, the oldest version (by access date) gets cleaned out. It's giving "you can stay, but somebody's gotta go." π
The strategy for which old versions get yeeted when space is needed is influenced by the attr argument. When attr is given, af_savecache goes looking for cached versions with the same name as the new one that are carrying the given attribute. If it finds one or more of those, the oldest one (again, access date) gets eliminated. π
The mode argument π
The mode argument can be one of these values:
AF_STORE_COMPLETEβ the default, bestie. The cached file is stored unmodified. No notes, just vibes.AF_STORE_COMPRESSEDβ the cached file gets stored in a compressed format.
a quick note on version numbers π
ASOs that are saved in derived object caches do not automatically get a version number. Periodt. If you want one, you can use af_svnum β that's on the manual page af_version(3) β to attach any version number you like to an ASO stored in a derived object cache. Main character energy, honestly. π
af_cachesize π
af_cachesize defines the size strategy of the cache in the directory path. It sets three things:
- the maximum cache size for the whole directory β that's
totalMaxπ₯ - the maximum number of versions per name β that's
maxPerName - the number of versions allowed simultaneously carrying the elimination attribute (yeah, the one from before) β that's
maxPerGivenAttr
And here's the little trick, bestie: if you give a value less than or equal to zero for any of the arguments of af_cachesize, that argument just gets ignored. No error, no drama, it simply doesn't count. π§
π¨ DIAGNOSTICS π¨
Upon error, -1 is returned and af_errno is set to the corresponding error number. So like, always check that return value, okay? π
π BUGS π
Compression of cached files (mode AF_STORE_COMPRESSED) is not yet supported. So don't come crying to me when you ask for compressed and get nothing, bestie. π«Ά
af_cachesize cannot shrink derived object caches yet. Any values you give must be greater than or equal to the previous size. It only grows, no cap. Actually wait β cap, because it can't shrink. π
π that's the page, bestie π
This lil slice of Unix history comes from AtFS-1.71, dated Mon Jul 19 18:19:37 1993. Yes, 1993 β vintage, archival, truly iconic behavior. Go forth and cache responsibly. πβ¨π
π¦ where this page comes from
- debian bookworm: atfs-dev 1.4pl6-15+b1
- ubuntu jammy: atfs-dev 1.4pl6-15
- ubuntu noble: atfs-dev 1.4pl6-16.1build1
- ubuntu resolute: atfs-dev 1.4pl6-17
- ubuntu stonking: atfs-dev 1.4pl6-17
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms