LLVM 20.0.0git
Public Member Functions | List of all members
llvm::FileCache Struct Reference

This type represents a file cache system that manages caching of files. More...

#include "llvm/Support/Caching.h"

Public Member Functions

 FileCache (FileCacheFunction CacheFn, const std::string &DirectoryPath)
 
 FileCache ()=default
 
Expected< AddStreamFnoperator() (unsigned Task, StringRef Key, const Twine &ModuleName)
 
const std::string & getCacheDirectoryPath () const
 
bool isValid () const
 

Detailed Description

This type represents a file cache system that manages caching of files.

It encapsulates a caching function and the directory path where the cache is stored. To request an item from the cache, pass a unique string as the Key. For hits, the cached file will be added to the link and this function will return AddStreamFn(). For misses, the cache will return a stream callback which must be called at most once to produce content for the stream. The file stream produced by the stream callback will add the file to the link after the stream is written to. ModuleName is the unique module identifier for the bitcode module the cache is being checked for.

Clients generally look like this:

if (AddStreamFn AddStream = Cache(Task, Key, ModuleName)) ProduceContent(AddStream);

CacheDirectoryPath stores the directory path where cached files are kept.

Definition at line 67 of file Caching.h.

Constructor & Destructor Documentation

◆ FileCache() [1/2]

llvm::FileCache::FileCache ( FileCacheFunction  CacheFn,
const std::string &  DirectoryPath 
)
inline

Definition at line 68 of file Caching.h.

◆ FileCache() [2/2]

llvm::FileCache::FileCache ( )
default

Member Function Documentation

◆ getCacheDirectoryPath()

const std::string & llvm::FileCache::getCacheDirectoryPath ( ) const
inline

Definition at line 77 of file Caching.h.

Referenced by llvm::cgdata::StreamCacheData::StreamCacheData().

◆ isValid()

bool llvm::FileCache::isValid ( ) const
inline

Definition at line 80 of file Caching.h.

Referenced by operator()(), and llvm::cgdata::StreamCacheData::StreamCacheData().

◆ operator()()

Expected< AddStreamFn > llvm::FileCache::operator() ( unsigned  Task,
StringRef  Key,
const Twine ModuleName 
)
inline

Definition at line 72 of file Caching.h.

References assert(), and isValid().


The documentation for this struct was generated from the following file: