11 #ifndef __FS_DiskCache__
12 #define __FS_DiskCache__
44 computeFilename(
value, suffix);
67 , myStoreInCache(false)
86 {
return write(buf.buffer(), buf.length()); }
95 bool isValid()
const {
return myFd >= 0; }
98 bool isRead()
const {
return myAccess & R_OK; }
101 bool isWrite()
const {
return myAccess & W_OK; }
115 exint fileSize()
const;
122 exint myBytesWritten;
159 myCacheHits += s.myCacheHits;
160 myCacheMiss += s.myCacheMiss;
161 myCacheError += s.myCacheError;
162 myFileCount += s.myFileCount;
163 myDiskSize += s.myDiskSize;
164 myPurgeCount += s.myPurgeCount;
198 myFileCount = nfiles;
217 time_t myLastRecompute;
221 exint default_size_in_bytes = 0);
225 bool isValid()
const {
return myPath.isstring(); }
284 void printLog(
const char *fmt, ...) const
287 template<typename... Args>
288 void log(const
char *fmt, const Args &...
args)
const
296 void cacheFilePath(
Accessor &
a,
const Key &k,
299 void initStats(Stats &
s)
const
301 s.myCachePath = myPath;
302 s.myMaxSize = myMaxSize;
303 s.myMaxLogSize = myMaxLogSize;
304 s.myCreateTime = myCreateTime;
305 s.myLastRecompute = myLastRecompute;
310 { statPath(a.filename(),
path); }
313 void cacheHit(
const Accessor &a)
const;
314 void cacheMiss(
const Accessor &a)
const;
315 void cachePurge(
const Accessor &a,
const char *filepath)
const;
318 void setDefaults(
exint default_size);
319 bool saveConfig()
const;
322 bool saveStats(
const char *path,
const Stats &
s)
const;
325 bool must_create,
bool in_cache)
const;
332 time_t myLastRecompute;
void merge(const Stats &s)
Merge stats from a different set of stats.
GLenum GLuint GLenum GLsizei const GLchar * buf
bool setMaxSize(int64 size_in_bytes=256 *1024 *1024)
Set the maximum data size of the cache.
GT_API const UT_StringHolder filename
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.
GLsizei const GLchar *const * path
void printLog(const char *fmt,...) const SYS_PRINTF_CHECK_ATTRIBUTE(2
SYS_FORCE_INLINE const char * buffer() const
GLboolean GLboolean GLboolean GLboolean a
void addCacheHit()
Update stats with a cache hit.
Class which writes ASCII or binary JSON streams.
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
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)
GLuint GLint GLboolean GLint GLenum access
#define SYS_PRINTF_CHECK_ATTRIBUTE(string_index, first_to_check)
New item, accessor has write-only file.
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
const UT_StringHolder & location() const
Return the location of the path.
const UT_StringHolder & filename() const
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
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.
size_t format(const char *fmt, const Args &...args)
void dump() const
Dump debug information about the cache.
bool recompute()
Reset the cache.
SIM_API const UT_StringHolder force
time_t createTime() const
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.
FS_DiskCache(const UT_StringHolder &path=UT_StringHolder(), exint default_size_in_bytes=0)
bool stats(Stats &stats) const
Get statistics for the cache.
**If you just want to fire and args
GLubyte GLubyte GLubyte GLubyte w
bool clearCache() const
Clear the cache contents.
OIIO_FORCEINLINE T log(const T &v)
bool isValid() const
Check to see if the cache is valid.
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Key(const UT_StringRef &value=UT_StringRef(), const UT_StringRef &suffix=UT_StringRef())
Existing item, accessor has read-only file.