11 #ifndef __FS_DiskCache__
12 #define __FS_DiskCache__
43 computeFilename(
value, suffix);
66 , myStoreInCache(false)
92 bool isValid()
const {
return myFd >= 0; }
95 bool isRead()
const {
return myAccess & R_OK; }
98 bool isWrite()
const {
return myAccess & W_OK; }
112 exint fileSize()
const;
119 exint myBytesWritten;
157 myCacheHits += s.myCacheHits;
158 myCacheMiss += s.myCacheMiss;
159 myCacheError += s.myCacheError;
160 myFileCount += s.myFileCount;
161 myDiskSize += s.myDiskSize;
162 myPurgeCount += s.myPurgeCount;
196 myFileCount = nfiles;
215 time_t myLastRecompute;
222 bool isValid()
const {
return myPath.isstring(); }
275 bool purge(
bool force=
false)
const;
284 template<typename... Args>
293 void cacheFilePath(
Accessor &
a,
const Key &k,
296 void initStats(Stats &
s)
const
298 s.myCachePath = myPath;
299 s.myMaxSize = myMaxSize;
300 s.myMaxLogSize = myMaxLogSize;
301 s.myCreateTime = myCreateTime;
302 s.myLastRecompute = myLastRecompute;
307 { statPath(a.filename(),
path); }
310 void cacheHit(
const Accessor &a)
const;
311 void cacheMiss(
const Accessor &a)
const;
312 void cachePurge(
const Accessor &a,
const char *filepath)
const;
316 bool saveConfig()
const;
319 bool saveStats(
const char *path,
const Stats &
s)
const;
322 bool must_create,
bool in_cache)
const;
329 time_t myLastRecompute;
void merge(const Stats &s)
Merge stats from a different set of stats.
vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
bool setMaxSize(int64 size_in_bytes=256 *1024 *1024)
Set the maximum data size of the cache.
GT_API const UT_StringHolder filename
SYS_FORCE_INLINE exint length() const
void reset(int64 nfiles, int64 size)
Reset the file count and size.
exint bytesWritten() const
Return the number of bytes written.
bool setMaxLogSize(int64 size_in_bytes=1024 *1024)
Set the maximum log size of the cache.
GLboolean GLboolean GLboolean GLboolean a
void printLog(const char *fmt,...) const SYS_PRINTF_CHECK_ATTRIBUTE(2
SYS_FORCE_INLINE const char * buffer() const
void addCacheHit()
Update stats with a cache hit.
Class which writes ASCII or binary JSON streams.
void read(T &in, bool &v)
bool isWrite() const
Whether the accessor was opened for writing.
time_t lastRecompute() const
InsertStatus
Possible return values for the insert() function.
void storeInCache(bool v)
GLint GLenum GLsizei GLint GLsizei const void * data
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
New item, accessor has write-only file.
GLubyte GLubyte GLubyte GLubyte w
const UT_StringHolder & location() const
Return the location of the path.
const UT_StringHolder & filename() const
OPENVDB_API void initialize()
Global registration of basic types.
Statistics for the cache.
bool isRead() const
Whether the accessor was opened as read-only.
int64 maxLogSize() const
Return the maximum size of the log file.
Unknown error, accessor will be invalid.
bool clobberCache()
Reset the cache entirely.
bool isValid() const
Whether the accessor is valid.
const UT_StringHolder & filename() const
Return the full path of the file in the cache.
GLsizei const GLchar *const * path
size_t format(const char *fmt, const Args &...args)
void dump() const
Dump debug information about the cache.
bool recompute()
Reset the cache.
time_t createTime() const
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
bool purge(bool force=false) const
Purge items from a cache to meet size requirements using LRU.
int64 maxSize() const
Return the maximum size of the cache.
bool stats(Stats &stats) const
Get statistics for the cache.
bool clearCache() const
Clear the cache contents.
void write(T &out, bool v)
GLenum GLuint GLsizei const GLchar * buf
FS_DiskCache(const UT_StringHolder &path=UT_StringHolder())
bool isValid() const
Check to see if the cache is valid.
GLsizei const GLfloat * value
Key(const UT_StringRef &value=UT_StringRef(), const UT_StringRef &suffix=UT_StringRef())
bool write(const UT_WorkBuffer &buf)
Convenience methods to write data to the cache.
Existing item, accessor has read-only file.