CBCache Class

Properties   Methods   Events   Config Settings   Errors  

The CBCache class allows applications to easily cache remote file data locally.

Syntax

class cbfsconnect.CBCache

Remarks

The CBCache class provides a local file-caching implementation that helps applications easily cache the contents of files stored in some external storage, such as a cloud storage service. Once an application has informed the CBCache class of the external storage's file transfer capabilities, the hard work of reading data into and flushing data out of the cache is handled automatically.

Getting Started

Applications typically need only a single instance of the CBCache class, because it can handle caching and accessing multiple files at once in parallel. Each file in the cache is identified by its file Id, and all cached file data are stored in a single cache storage file, whose name and location are determined by the cache_file and cache_directory properties, respectively.

In terms of application architecture, the CBCache class (or, more generally, the cache itself) should reside between application code that needs random access to files in the external storage, and the code that provides access to said external storage. The former makes use of the CBCache class's properties and methods, while the latter is "connected" through the class's on_read_data and on_write_data events.

Here's how to get up and running:

  1. Implement the on_read_data and on_write_data events so that they provide appropriate access to the external storage. The on_read_data event is mandatory. The on_write_data event is required only if the CBCache class is to be in charge of flushing changed data back to external storage. Refer to these events' documentation for more information about how to correctly implement them.
  2. "Describe" the reading, writing, and resizing capabilities of the external storage to the CBCache class by setting the reading_capabilities, writing_capabilities, and resizing_capabilities properties. This information is used by the CBCache class to formulate a strategy for interacting with the external storage through the events mentioned in step 1.
  3. Open the cache by setting the cache_directory and cache_file properties, and then calling the open_cache method.
  4. When the class opens an existing cache vault, it is recommended that applications use the enumerate_cached_files method to search for any Orphan Files (i.e., files that are not currently open have unflushed data). If any such files are found, applications may wish to open, flush, or delete them.
  5. To create or open a file in the cache (i.e., a cached file), call the file_open method.
  6. While a cached file is open, it can be read from or written to using the file_read and file_write methods.

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

activeThis property describes whether the file cache is open.
auto_flushThis property specifies whether automatic flushing is enabled.
cache_directoryThis property includes the directory in which the cache's storage file is located.
cache_fileThis property includes the name of the file cache.
cache_size_limitThis property includes the maximum size of the cache's storage file.
compressedThis property specifies whether or not the cache's storage file should be compressed.
flush_after_close_delayThis property includes the number of seconds to delay flushing after a file is closed.
flush_after_sizeThis property includes the amount of data that must be changed for flushing to begin.
flush_after_timeThis property includes the inactivity timeout that must elapse for flushing to begin.
flush_policyThis property includes the file flushing strategy that the cache should use.
has_orphansThis property notes whether or not the cache contains any orphan files.
max_cached_file_sizeThis property includes the maximum amount of data that should be cached for any given file.
modeThis property includes the mode in which the cache operates in regard to access to the external storage.
offlineThis property specifies whether or not the cache works in Offline mode.
purge_after_close_delayThis property includes the number of seconds to delay purging for after a file is closed.
purge_after_timeThis property includes the inactivity timeout that must elapse for purging to begin.
purge_policyThis property includes the file block purging strategy that the cache should use.
read_block_sizeThis property includes the block size to use when reading file data from external storage.
reading_capabilitiesThis property includes the reading capabilities supported by the external storage.
resizing_capabilitiesThis property includes the file resizing capabilities supported by the external storage.
serializationThis property specifies whether nonintersecting operations against the same file or cache should execute serially or in parallel.
stats_cache_sizeThis property contains the current size of the cache.
stats_current_file_idThis property contains the file currently being read or written by the cache.
stats_current_operationThis property contains the operation currently being performed by the cache.
stats_total_dataThis property contains the total amount of data present in the cache.
stats_unflushed_dataThis property contains the amount of unflushed data present in the cache.
stats_unflushed_filesThis property contains the number of unflushed files present in the cache.
tagThis property stores application-defined data specific to a particular instance of the class.
write_block_sizeThis property includes the block size to use when writing file data to external storage.
writing_capabilitiesThis property includes the writing capabilities supported by the external storage.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

cancel_cleanupThis method cancels a background cleanup operation, if necessary.
check_and_repairThis method checks a cache vault's consistency and repairs it as necessary.
clearThis method removes files from the cache.
close_cacheThis method closes the cache.
close_enumerationThis method closes the given file enumeration.
configSets or retrieves a configuration setting.
delete_cacheThis method deletes the cache completely.
enumerate_cached_filesThis method enumerates the files in the cache.
file_change_idThis method changes the Id of a cached file.
file_closeThis method closes a cached file.
file_close_exThis method closes a cached file, specifying flushing and purging behaviors explicitly.
file_deleteThis method deletes a file from the cache.
file_existsThis method checks if a file with the given Id is present in the cache.
file_flushThis method flushes the specified file's modified blocks out to external storage.
file_get_pinnedThis method returns the pinned state of a cached file.
file_get_sizeThis method gets the "real size" of a cached file.
file_get_statusThis method gets the status of a cached file.
file_openThis method opens the specified cached file, creating it if necessary.
file_open_exThis method opens the specified cached file, creating it if necessary.
file_purgeThis method purges unmodified data from the cache.
file_readThis method reads the specified part of a cached file.
file_set_pinnedThis method sets the pinned state of a cached file.
file_set_sizeThis method sets the "real size" of a cached file.
file_set_size_exThis method sets the "real size" of a cached file.
file_tag_deleteThis method deletes a file tag.
file_tag_existsThis method checks whether or not a file has a specific tag associated with it.
file_tag_getThis method retrieves the binary data held by a file tag attached to the specified cached file.
file_tag_get_sizeThis method retrieves the size of a file tag attached to the specified cached file.
file_tag_setThis method attaches a file tag with binary data to the specified cached file.
file_touchThis method touches a range of data in a cached file.
file_writeThis method writes the specified part of a cached file.
get_next_enumerated_fileThis method returns the next file in the list of enumeration results.
open_cacheThis method opens the cache.
refresh_statisticsThis method forces a refresh of the cache's statistics.
reset_error_stateThis method resets any outstanding errors for a file or external storage.
start_cleanupThis method starts a background cleanup operation to remove unused files from the cache.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_before_flushThis event fires to report the start of the asynchronous file flush procedure.
on_before_purgeThis event fires to report the start of the asynchronous file purge procedure.
on_end_cleanupThis event fires to report the beginning of the asynchronous cleanup procedure.
on_errorThis event fires if an unhandled error occurs during an event.
on_logThis log reports events that occur in the class.
on_progressThis event fires to report the progress of an operation.
on_read_dataThis event fires when the cache needs to read file data from external storage.
on_start_cleanupThis event fires to report the beginning of the asynchronous cleanup procedure.
on_statusThis event fires to report the latest cache statistics.
on_write_dataThis event fires when the cache needs to write file data to external storage.

Config Settings


The following is a list of config settings for the class with short descriptions. Click on the links for further details.

BlockSizeThe size of the block, used to store the data.
JournalingModeSpecifies whether the main cache file uses journaling for increased data consistency.
LogLevelThe level of detail that is logged.
MaxReaderThreadsPerFileThe maximum number of reader threads to use to fire events.
StatsRefreshIntervalMinimum time period between cache statistics refreshes.
StoreDataInFilesSpecifies whether file data should be stored in the main cache file or in individual files.
BuildInfoInformation about the product's build.
LicenseInfoInformation about the current license.

active Property

This property describes whether the file cache is open.

Syntax

def get_active() -> bool: ...

active = property(get_active, None)

Default Value

FALSE

Remarks

This property reflects whether the class has opened a file cache; it will be True once the open_cache method has been called successfully.

This property is read-only.

auto_flush Property

This property specifies whether automatic flushing is enabled.

Syntax

def get_auto_flush() -> bool: ...
def set_auto_flush(value: bool) -> None: ...

auto_flush = property(get_auto_flush, set_auto_flush)

Default Value

TRUE

Remarks

This property specifies whether automatic flushing is enabled. When this property is enabled (default), automatic flushing will take place both according to the flush_policy setting, and when cached files are closed (after any delay specified by the flush_after_close_delay property).

If this property is disabled, automatic flushing will never occur, regardless of the flush_policy setting; however, the file_flush method can still be used to explicitly flush a cached file.

Typically, applications should disable this property only in cases in which they need to suspend background write operations for some reason (e.g., if connectivity with the external storage is temporarily lost).

cache_directory Property

This property includes the directory in which the cache's storage file is located.

Syntax

def get_cache_directory() -> str: ...
def set_cache_directory(value: str) -> None: ...

cache_directory = property(get_cache_directory, set_cache_directory)

Default Value

""

Remarks

This property specifies the path of the directory in which the cache's storage file is located. The name of the cache's storage file is derived from the cache_file property.

Note: This property cannot be changed when active is True.

cache_file Property

This property includes the name of the file cache.

Syntax

def get_cache_file() -> str: ...
def set_cache_file(value: str) -> None: ...

cache_file = property(get_cache_file, set_cache_file)

Default Value

""

Remarks

This property specifies the name of the file cache. This name is used to create the cache's storage file in the directory specified by the cache_directory property.

Note: This property cannot be changed when active is True.

cache_size_limit Property

This property includes the maximum size of the cache's storage file.

Syntax

def get_cache_size_limit() -> int: ...
def set_cache_size_limit(value: int) -> None: ...

cache_size_limit = property(get_cache_size_limit, set_cache_size_limit)

Default Value

0

Remarks

This property specifies the maximum size, in megabytes, that the cache's storage file is allowed to grow to. If this limit is reached, the cache will initiate a background cleanup operation automatically, purging file data according to the purge_policy and shrinking the cache storage file afterward. By default, this property is set to 0, which means "no limit".

Note: Any purging and shrinking attempts caused by this property's value are made on a "best effort" basis, which can be affected by the following:

  • The amount of unflushed data present in the cache (as indicated by the stats property): if it is greater than the specified size limit, the cache will not be able to purge said data or shrink its storage file until enough data have been flushed.
  • The purge_policy property: certain values can make it impossible for the cache to immediately perform the required purging.

Note: This property cannot be changed when active is True.

compressed Property

This property specifies whether or not the cache's storage file should be compressed.

Syntax

def get_compressed() -> bool: ...
def set_compressed(value: bool) -> None: ...

compressed = property(get_compressed, set_compressed)

Default Value

FALSE

Remarks

This property specifies whether or not the cache's storage file should be compressed.

If the StoreDataInFiles configuration setting is enabled, the Compressed property affects only the main cache storage file and not the files used to store individual files' data.

Note: This property cannot be changed when active is True.

flush_after_close_delay Property

This property includes the number of seconds to delay flushing after a file is closed.

Syntax

def get_flush_after_close_delay() -> int: ...
def set_flush_after_close_delay(value: int) -> None: ...

flush_after_close_delay = property(get_flush_after_close_delay, set_flush_after_close_delay)

Default Value

30

Remarks

This property specifies the number of seconds that flushing will be delayed after a file with unflushed blocks is closed. A value of 0 will cause such files to be flushed immediately upon close.

Flush-after-close delays are intended to prevent excessive flushing operations in cases in which a file is opened, written to, and closed many times in succession within the delay period.

Note: This property cannot be changed when active is True.

flush_after_size Property

This property includes the amount of data that must be changed for flushing to begin.

Syntax

def get_flush_after_size() -> int: ...
def set_flush_after_size(value: int) -> None: ...

flush_after_size = property(get_flush_after_size, set_flush_after_size)

Default Value

1

Remarks

When the flush_policy property is set to fpSize, fpSizeOrTime, or fpSizeAndTime, this property specifies how many megabytes of a file's data must be changed for flushing to begin.

Changed data thresholds are intended to prevent excessive flushing in cases in which data are written to the same range of a file many times in succession.

Note: This property cannot be changed when active is True.

flush_after_time Property

This property includes the inactivity timeout that must elapse for flushing to begin.

Syntax

def get_flush_after_time() -> int: ...
def set_flush_after_time(value: int) -> None: ...

flush_after_time = property(get_flush_after_time, set_flush_after_time)

Default Value

30

Remarks

When the flush_policy property is set to fpTime, fpSizeOrTime, or fpSizeAndTime, this property specifies how many seconds of inactivity (i.e., time with no writes) must elapse for a file before flushing can begin.

Inactivity delays are intended to prevent excessive flushing in cases in which data are written to a file many times in succession within the inactivity period.

Note: This property cannot be changed when active is True.

flush_policy Property

This property includes the file flushing strategy that the cache should use.

Syntax

def get_flush_policy() -> int: ...
def set_flush_policy(value: int) -> None: ...

flush_policy = property(get_flush_policy, set_flush_policy)

Default Value

2

Remarks

This property specifies the strategy that the cache should use for flushing-changed file data of the opened file out to external storage. It must be set to one of the following values:

fpNone (0) No automatic flushing. Use this setting to have the file written only after it is closed. Use the flush_after_close_delay property to control the delay between file closing and writing of file data.
fpSize (1) Flush a file when the amount of changed data exceeds a certain limit. The flush_after_size property specifies the size limit.
fpTime (2) (default) Flush a file when it has not been written to for a certain amount of time. The flush_after_time property specifies the time limit.
fpSizeOrTime (3) Flush a file when the amount of changed data exceeds a certain limit OR when it has not been written to for a certain amount of time. The flush_after_size and flush_after_time properties specify the size and time limits, respectively.
fpSizeAndTime (4) Flush a file when the amount of changed data exceeds a certain limit AND when it has not been written to for a certain amount of time. The flush_after_size and flush_after_time properties specify the size and time limits, respectively.

Note: This property cannot be changed when active is True.

has_orphans Property

This property notes whether or not the cache contains any orphan files.

Syntax

def get_has_orphans() -> bool: ...

has_orphans = property(get_has_orphans, None)

Default Value

FALSE

Remarks

This property specifies whether or not the cache contains any Orphan Files, returning True if so or False otherwise.

Note: This property returns a valid value only when active is True.

This property is read-only.

max_cached_file_size Property

This property includes the maximum amount of data that should be cached for any given file.

Syntax

def get_max_cached_file_size() -> int: ...
def set_max_cached_file_size(value: int) -> None: ...

max_cached_file_size = property(get_max_cached_file_size, set_max_cached_file_size)

Default Value

0

Remarks

This property specifies the maximum amount of data, in bytes, that the cache should store for any given file. When a file reaches this limit, the cache will start dropping its least-recently accessed unchanged blocks.

The default value of 0 means "no limit", causing all file data to be kept in the cache at least until the file is closed (and possibly longer, depending on how the cache is configured).

mode Property

This property includes the mode in which the cache operates in regard to access to the external storage.

Syntax

def get_mode() -> int: ...
def set_mode(value: int) -> None: ...

mode = property(get_mode, set_mode)

Default Value

0

Remarks

This property specifies the mode of operations that the cache should use for reading and writing the data. Possible values are as follows:

cmNormal (0) (default) Regular cached reading and writing are performed.
cmShadow (1) The cache reads the data from the external storage, but it does not do any writes.
cmPassthrough (2) The cache does not store file data locally and serves read/write requests by firing the corresponding events synchronously.
cmMirror (3) Reading is performed as in the Normal mode. Writing is done synchronously both to the local cache and to the external storage. The file_write method returns when the data are flushed to the external storage or if the error occurs during this operation.

Note: This property cannot be changed when active is True.

offline Property

This property specifies whether or not the cache works in Offline mode.

Syntax

def get_offline() -> bool: ...
def set_offline(value: bool) -> None: ...

offline = property(get_offline, set_offline)

Default Value

FALSE

Remarks

This property specifies whether or not the cache works in Offline mode. When in this mode, no events are fired to read or write data from/to the external storage.

This property is different from auto_flush: auto_flush prevents automated flushing but allows reading and manual flushing, whereas the Offline mode prevents both reading and writing, which means that application-initiated flushing does nothing as well.

purge_after_close_delay Property

This property includes the number of seconds to delay purging for after a file is closed.

Syntax

def get_purge_after_close_delay() -> int: ...
def set_purge_after_close_delay(value: int) -> None: ...

purge_after_close_delay = property(get_purge_after_close_delay, set_purge_after_close_delay)

Default Value

30

Remarks

When the purge_policy property is set to ppFileClose, this property specifies the number of seconds that purging will be delayed for after a file without any unflushed blocks is closed. A value of 0 will cause such files to be purged immediately on close.

Purge-after-close delays are intended to prevent excessive fetching of data from external storage in cases in which a file is opened and closed many times in succession within the delay period.

Note: This property cannot be changed when active is True.

purge_after_time Property

This property includes the inactivity timeout that must elapse for purging to begin.

Syntax

def get_purge_after_time() -> int: ...
def set_purge_after_time(value: int) -> None: ...

purge_after_time = property(get_purge_after_time, set_purge_after_time)

Default Value

2592000

Remarks

When the purge_policy property is set to ppTime, this property specifies the number of seconds that a file data block must remain unchanged for before it is purged from the cache. Because the cache is intended for longer-time data storage and all data survive cache restart, the default value is 30 days.

Note: This property cannot be changed when active is True.

purge_policy Property

This property includes the file block purging strategy that the cache should use.

Syntax

def get_purge_policy() -> int: ...
def set_purge_policy(value: int) -> None: ...

purge_policy = property(get_purge_policy, set_purge_policy)

Default Value

3

Remarks

This property specifies the strategy that the cache should use for purging unmodified blocks of file data from the cache. It must be set to one of the following values:

ppNone (0) (default) No automatic purging. Use the start_cleanup method to perform cache cleanup.
ppFileClose (1) Purge files as they are closed (after a delay). The purge_after_close_delay property specifies the delay interval.
ppCacheClose (2) Purge files when the cache is closed (without a delay).
ppTime (3) Purge files when they have not been accessed for a certain time. The purge_after_time property specifies the time a file must not be accessed for it to be purged.

Note: This property cannot be changed when active is True.

read_block_size Property

This property includes the block size to use when reading file data from external storage.

Syntax

def get_read_block_size() -> int: ...
def set_read_block_size(value: int) -> None: ...

read_block_size = property(get_read_block_size, set_read_block_size)

Default Value

1048576

Remarks

This property specifies the block size, in bytes, that the class should use when reading data from external storage through the on_read_data event.

Note: In some cases (e.g., when reading the last part of a file), the amount of requested data may be less than the value specified by this property.

Applications should always set this property to a reasonable value (or use the default value), even if the reading_capabilities property specifies that the external storage supports only whole-file reading.

This property may be overridden by the corresponding parameter of the file_open and file_set_size methods.

Changing this property causes the BlockSize configuration setting's value to be recalculated.

Note: This property cannot be changed when active is True.

reading_capabilities Property

This property includes the reading capabilities supported by the external storage.

Syntax

def get_reading_capabilities() -> int: ...
def set_reading_capabilities(value: int) -> None: ...

reading_capabilities = property(get_reading_capabilities, set_reading_capabilities)

Default Value

1048

Remarks

This property specifies any and all behaviors of the external storage that are relevant when reading data from it. The class will automatically alter its behavior based on this property's "description" of how the external storage is able to provide file data.

This property should be set by ORing together zero or more of the flags defined in the following. These flags are grouped by name to specify the operations to which they apply.

Flag Group Description
Position Flags with POS in the name describe where read and writes can occur from.
Size Flags with SIZE in the name describe the sizes of read and writes the external data source supports.
Write Flags with WRITE in the name describe flags that are specific to write operations.
Supplemental Flags with SUPPL in the name describe flags that are used to further specify the expectations of the external data source.

Reading and Writing Capability Flags (Position Related)

RWCAP_POS_SEQUENTIAL_FROM_BOF0x00000001No random access allowed; read/write operations must start at the beginning of a file.

When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_POS_BLOCK_MULTIPLE0x00000004Reading/writing is possible at positions that are multiple of the corresponding block size.

The read and write block sizes are specified by the read_block_size and write_block_size properties . When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_POS_RANDOM0x00000008Reading/writing is possible at any position.

When this flag is used, other flags can still alter the positions at which reading/writing are possible.

RWCAP_POS_SUPPL_ONLY_WITHIN_FILE0x00000010File position must remain in the range: 0 <= FilePos < FileSize

Reading and Writing Capability Flags (Size Related)

RWCAP_SIZE_WHOLE_FILE0x00000100Only whole-file reads/writes are possible; partial reads/writes are not supported.

Note:

  • The read_block_size and write_block_size properties should still be set to reasonable values when using this flag.
  • Use one of the other RWCAP_SIZE_* flags instead of this one if the external storage supports reading subsets of the file.
When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_SIZE_FIXED_BLOCKS_WITH_TAIL0x00000200Reads/writes must be done in blocks of a fixed size, except for the last block, which may be of any size.

When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_SIZE_FIXED_BLOCKS_NO_TAIL0x00000400Reads/writes must be done in blocks of a fixed size, including the last block.

Note: Real file sizes, if needed, must be stored elsewhere when using the cache with an external storage medium that has this characteristic.

When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_SIZE_ANY0x00000800Reads/writes may be done in blocks of any size.

Reading and Writing Capability Flags (Write Related)

RWCAP_WRITE_APPEND_ONLY0x00000002Append only; write operations must start at the end of a file.

To overwrite a file, it must first be truncated, and then written to. (Truncation behavior is defined by the corresponding flags.)

RWCAP_WRITE_SUPPL_NOT_BEYOND_EOF0x00000020File position remain in the range: 0 <= FilePos <= FileSize

When writing, appending to the end of the file is supported, but writing at positions past the end of the file is not.

RWCAP_WRITE_TRUNCATES_FILE0x00001000When writes occur, the last data written becomes the new end of the file.

Any overwritten data, and any data previously present after the written range, are lost.

RWCAP_WRITE_KEEPS_FILESIZE0x00002000Normal writing behavior (i.e., writes do not alter a file's size, except possibly to expand it).

RWCAP_WRITE_NOT_BEYOND_EOF0x00004000Writes may not extend past the end of a file's current size (i.e., cannot cause a file to grow).

Applications may still adjust the file size beforehand.

Note: This property cannot be changed when active is True.

resizing_capabilities Property

This property includes the file resizing capabilities supported by the external storage.

Syntax

def get_resizing_capabilities() -> int: ...
def set_resizing_capabilities(value: int) -> None: ...

resizing_capabilities = property(get_resizing_capabilities, set_resizing_capabilities)

Default Value

51

Remarks

This property specifies any and all behaviors of the external storage that are relevant when resizing files. The class will automatically alter its behavior based on this property's "description" of how the external storage is able to resize files.

This property should be set by ORing together zero or more of the following flags:

RSZCAP_GROW_TO_ANY0x00000001Files can grow to any size.

RSZCAP_SHRINK_TO_ANY0x00000002Files can shrink to any size.

RSZCAP_GROW_TO_BLOCK_MULTIPLE0x00000004Files can grow to sizes that are a multiple of the block size.

RSZCAP_SHRINK_TO_BLOCK_MULTIPLE0x00000008Files can shrink to sizes that are a multiple of the block size.

RSZCAP_TRUNCATE_ON_OPEN0x00000010The external storage (or application itself) supports truncating a file when it is opened for writing.

RSZCAP_TRUNCATE_AT_ZERO0x00000020The external storage (or application itself) supports truncating a file to zero at any time (not just when it is being opened).

Note: This property cannot be changed when active is True.

serialization Property

This property specifies whether nonintersecting operations against the same file or cache should execute serially or in parallel.

Syntax

def get_serialization() -> int: ...
def set_serialization(value: int) -> None: ...

serialization = property(get_serialization, set_serialization)

Default Value

3

Remarks

This property specifies whether the class should force nonintersecting operations against a single file or whole cache to execute serially, or allow them to execute in parallel.

smNone (0) "No serialization", the component does not serialize anything and leaves this task to the user. The same as smPerFileReadingWritingConcurrent serialization mode.
smGlobal (1) "Global", all events are serialized; it is assumed that the user has one instance of code (e.g., class, component) that is capable of handling one request at a time.
smPerFileAllOperations (2) "Per-file, all operations", all operations on a single file are serialized; however, operations with different files may be concurrent.
smPerFileReadingWritingConcurrent (3)(default)"Per-file, reading and writing concurrent", reading and writing to a single file may be concurrent, but access to different ranges is serialized.
smPerFileReadingConcurrent (4) "Per-file, reading concurrent", reading of different ranges of the same file may be concurrent, while writing of different blocks of the file will be serialized.

Note: This property cannot be changed when active is True.

stats_cache_size Property

This property contains the current size of the cache.

Syntax

def get_stats_cache_size() -> int: ...

stats_cache_size = property(get_stats_cache_size, None)

Default Value

0

Remarks

This property contains the current size of the cache.

This property reflects the current size, in bytes, of the file cache.

Properties related to cache statistics are refreshed periodically based on the interval specified by the StatsRefreshInterval configuration setting. Applications that need fresher data can either decrease the update refresh, or call the refresh_statistics method to force an immediate refresh.

Note: This property returns a valid value only when active is True.

This property is read-only.

stats_current_file_id Property

This property contains the file currently being read or written by the cache.

Syntax

def get_stats_current_file_id() -> str: ...

stats_current_file_id = property(get_stats_current_file_id, None)

Default Value

""

Remarks

This property contains the file currently being read or written by the cache.

When stats_current_operation is CACHE_OP_READ or CACHE_OP_WRITE, this property will reflect the Id of the file being read or written. Otherwise, it will return an empty string.

Properties related to cache statistics are refreshed periodically based on the interval specified by the StatsRefreshInterval configuration setting. Applications that need fresher data can either decrease the update refresh, or call the refresh_statistics method to force an immediate refresh.

Note: This property returns a valid value only when active is True.

This property is read-only.

stats_current_operation Property

This property contains the operation currently being performed by the cache.

Syntax

def get_stats_current_operation() -> int: ...

stats_current_operation = property(get_stats_current_operation, None)

Default Value

0

Remarks

This property contains the operation currently being performed by the cache.

This property reflects the operation currently being performed by the cache. It will be one of the following values:

CACHE_OP_IDLE0The cache is idle.

CACHE_OP_CLEANUP2Cache cleanup is being performed.

CACHE_OP_COMPACT3The cache's storage file is being compacted.

CACHE_OP_READ4The cache is reading some file's data.

CACHE_OP_WRITE5The cache is writing some file's data.

Properties related to cache statistics are refreshed periodically based on the interval specified by the StatsRefreshInterval configuration setting. Applications that need fresher data can either decrease the update refresh, or call the refresh_statistics method to force an immediate refresh.

Note: This property returns a valid value only when active is True.

This property is read-only.

stats_total_data Property

This property contains the total amount of data present in the cache.

Syntax

def get_stats_total_data() -> int: ...

stats_total_data = property(get_stats_total_data, None)

Default Value

0

Remarks

This property contains the total amount of data present in the cache.

This property reflects the total amount of data, in bytes, currently present in the cache.

Properties related to cache statistics are refreshed periodically based on the interval specified by the StatsRefreshInterval configuration setting. Applications that need fresher data can either decrease the update refresh, or call the refresh_statistics method to force an immediate refresh.

Note: This property returns a valid value only when active is True.

This property is read-only.

stats_unflushed_data Property

This property contains the amount of unflushed data present in the cache.

Syntax

def get_stats_unflushed_data() -> int: ...

stats_unflushed_data = property(get_stats_unflushed_data, None)

Default Value

0

Remarks

This property contains the amount of unflushed data present in the cache.

This property reflects the amount of unflushed or modified data, in bytes, currently present in the cache.

Properties related to cache statistics are refreshed periodically based on the interval specified by the StatsRefreshInterval configuration setting. Applications that need fresher data can either decrease the update refresh, or call the refresh_statistics method to force an immediate refresh.

Note: This property returns a valid value only when active is True.

This property is read-only.

stats_unflushed_files Property

This property contains the number of unflushed files present in the cache.

Syntax

def get_stats_unflushed_files() -> int: ...

stats_unflushed_files = property(get_stats_unflushed_files, None)

Default Value

0

Remarks

This property contains the number of unflushed files present in the cache.

This property reflects the number of files with unflushed or modified data currently present in the cache.

Properties related to cache statistics are refreshed periodically based on the interval specified by the StatsRefreshInterval configuration setting. Applications that need fresher data can either decrease the update refresh, or call the refresh_statistics method to force an immediate refresh.

Note: This property returns a valid value only when active is True.

This property is read-only.

tag Property

This property stores application-defined data specific to a particular instance of the class.

Syntax

def get_tag() -> int: ...
def set_tag(value: int) -> None: ...

tag = property(get_tag, set_tag)

Default Value

0

Remarks

This property can be used to store data specific to a particular instance of the class.

write_block_size Property

This property includes the block size to use when writing file data to external storage.

Syntax

def get_write_block_size() -> int: ...
def set_write_block_size(value: int) -> None: ...

write_block_size = property(get_write_block_size, set_write_block_size)

Default Value

1048576

Remarks

This property specifies the block size, in bytes, that the class should use when writing data to external storage via the on_write_data event.

Note: In some cases (e.g., when writing the last part of a file), the amount of data being written may be less than the value specified by this property.

Applications should always set this property to a reasonable value (or use the default value), even if the writing_capabilities property specifies that the external storage only supports whole-file writing.

The property may be overridden by the corresponding parameter of the file_open and file_set_size methods.

Changing this property causes the BlockSize configuration setting's value to be recalculated.

Note: This property cannot be changed when active is True.

writing_capabilities Property

This property includes the writing capabilities supported by the external storage.

Syntax

def get_writing_capabilities() -> int: ...
def set_writing_capabilities(value: int) -> None: ...

writing_capabilities = property(get_writing_capabilities, set_writing_capabilities)

Default Value

9256

Remarks

This property specifies any and all behaviors of the external storage that are relevant when writing data to it. The class will automatically alter its behavior based on this property's "description" of how the external storage is able to write file data.

This property should be set by ORing together zero or more of the flags defined as follows. The flags are grouped by name to specify the operations to which they apply.

Flag Group Description
Position Flags with POS in the name describe where read and writes can occur from.
Size Flags with SIZE in the name describe the sizes of read and writes the external data source supports.
Write Flags with WRITE in the name describe flags that are specific to write operations.
Supplemental Flags with SUPPL in the name describe flags that are used to further specify the expectations of the external data source.

Reading and Writing Capability Flags (Position Related)

RWCAP_POS_SEQUENTIAL_FROM_BOF0x00000001No random access allowed; read/write operations must start at the beginning of a file.

When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_POS_BLOCK_MULTIPLE0x00000004Reading/writing is possible at positions that are multiple of the corresponding block size.

The read and write block sizes are specified by the read_block_size and write_block_size properties . When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_POS_RANDOM0x00000008Reading/writing is possible at any position.

When this flag is used, other flags can still alter the positions at which reading/writing are possible.

RWCAP_POS_SUPPL_ONLY_WITHIN_FILE0x00000010File position must remain in the range: 0 <= FilePos < FileSize

Reading and Writing Capability Flags (Size Related)

RWCAP_SIZE_WHOLE_FILE0x00000100Only whole-file reads/writes are possible; partial reads/writes are not supported.

Note:

  • The read_block_size and write_block_size properties should still be set to reasonable values when using this flag.
  • Use one of the other RWCAP_SIZE_* flags instead of this one if the external storage supports reading subsets of the file.
When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_SIZE_FIXED_BLOCKS_WITH_TAIL0x00000200Reads/writes must be done in blocks of a fixed size, except for the last block, which may be of any size.

When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_SIZE_FIXED_BLOCKS_NO_TAIL0x00000400Reads/writes must be done in blocks of a fixed size, including the last block.

Note: Real file sizes, if needed, must be stored elsewhere when using the cache with an external storage medium that has this characteristic.

When this flag is used in writing capabilities, the class can initiate reading of missing data before writing the changes to build the complete dataset, which is required for correct write operations.

RWCAP_SIZE_ANY0x00000800Reads/writes may be done in blocks of any size.

Reading and Writing Capability Flags (Write Related)

RWCAP_WRITE_APPEND_ONLY0x00000002Append only; write operations must start at the end of a file.

To overwrite a file, it must first be truncated, and then written to. (Truncation behavior is defined by the corresponding flags.)

RWCAP_WRITE_SUPPL_NOT_BEYOND_EOF0x00000020File position remain in the range: 0 <= FilePos <= FileSize

When writing, appending to the end of the file is supported, but writing at positions past the end of the file is not.

RWCAP_WRITE_TRUNCATES_FILE0x00001000When writes occur, the last data written becomes the new end of the file.

Any overwritten data, and any data previously present after the written range, are lost.

RWCAP_WRITE_KEEPS_FILESIZE0x00002000Normal writing behavior (i.e., writes do not alter a file's size, except possibly to expand it).

RWCAP_WRITE_NOT_BEYOND_EOF0x00004000Writes may not extend past the end of a file's current size (i.e., cannot cause a file to grow).

Applications may still adjust the file size beforehand.

Note: This property cannot be changed when active is True.

cancel_cleanup Method

This method cancels a background cleanup operation, if necessary.

Syntax

def cancel_cleanup() -> None: ...

Remarks

This method cancels any cleanup operation currently being performed in the background. If no such operation is running, this method does nothing.

check_and_repair Method

This method checks a cache vault's consistency and repairs it as necessary.

Syntax

def check_and_repair(encryption_password: str, flags: int) -> None: ...

Remarks

This method checks the consistency of a cache vault and attempts to repair it as necessary. Please refer to the Cache Corruption topic for more information.

Applications should call this method if a vault has become corrupted (if a cache operation fails with a ERROR_INTERNAL_VAULT_CORRUPTED error). Be sure to make a vault backup before calling this method, as its repair efforts may cause data loss in cases of severe corruption.

The Flags parameter is used to specify additional options and should be set by OR-ing together zero or more of the following flags:

CACHE_CHECK_NO_RECREATE_VAULT0x00000000If the vault is damaged beyond repair, report an error.

When this flag is used, the check_and_repair will return an error if the vault could not be repaired.

CACHE_CHECK_RECREATE_VAULT0x00000001If the vault is damaged beyond repair, recreate the vault automatically.

When this flag is used, the check_and_repair will delete the damaged vault and create a new one instead.

Note: This method cannot be called when active is True, and it cannot be called within events.

clear Method

This method removes files from the cache.

Syntax

def clear(remove_orphans: bool, remove_locals: bool) -> None: ...

Remarks

This method removes all files from the cache that are fully flushed and currently closed. Depending on the value passed for RemoveOrphans and RemoveLocals, Orphan Files and/or Local Files also may be removed as well.

The operation is performed synchronously, so this method returns once all applicable files have been removed. During the operation, the on_progress event will fire periodically to indicate progress.

close_cache Method

This method closes the cache.

Syntax

def close_cache(flush_action: int, purge_action: int) -> None: ...

Remarks

This method closes the cache, optionally performing file flushing and purging operations before doing so.

The FlushAction parameter specifies what kind of flushing to perform, if any. It must be one of the following values:

FLUSH_DELAYED0Flush as usual, taking into account any specified delay.

The flush_after_close_delay property specifies the delay. Passing this value to file_close or file_close_ex will cause the method to return immediately; flushing is performed in the background. Passing this value to close_cache has no effect (i.e., the cache is not flushed before being closed).

FLUSH_NONE1Do not flush anything.

FLUSH_IMMEDIATE2Flush immediately.

Passing this value to file_close, file_close_ex, and close_cache will cause the method to return only after all flushing operations are complete.

The PurgeAction parameter specifies what kind of purging to perform, if any. It must be one of the following values:

PURGE_DELAYED0Purge as usual, taking into account any specified delay.

The purge_after_close_delay property specifies the delay. Passing this value to file_close or file_close_ex will cause the method to return immediately; purging is performed in the background. Passing this value to close_cache has no effect; the cache is not purged before being closed.

PURGE_NONE1Do not purge anything.

PURGE_IMMEDIATE2Purge immediately.

Passing this value to file_close, file_close_ex, or close_cache will cause the method to return only after all purging operations are complete.

close_enumeration Method

This method closes the given file enumeration.

Syntax

def close_enumeration(enumeration_handle: int) -> None: ...

Remarks

This method closes the file enumeration identified by EnumerationHandle and releases any associated resources.

config Method

Sets or retrieves a configuration setting.

Syntax

def config(configuration_string: str) -> str: ...

Remarks

config is a generic method available in every class. It is used to set and retrieve configuration settings for the class.

These settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the config method.

To set a configuration setting named PROPERTY, you must call Config("PROPERTY=VALUE"), where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY"). The value will be returned as a string.

delete_cache Method

This method deletes the cache completely.

Syntax

def delete_cache() -> None: ...

Remarks

This method deletes the cache specified by the cache_file property completely, removing its storage file from the directory specified by the cache_directory property. If the cache is currently open, it is closed first.

enumerate_cached_files Method

This method enumerates the files in the cache.

Syntax

def enumerate_cached_files(enumeration_mode: int) -> int: ...

Remarks

This method initiates a enumeration operation for cached files that match the specified EnunmerationMode, which must be take of the following values:

ENUM_MODE_ALL0Enumerate all files.

ENUM_MODE_CHANGED1Enumerate files with changed blocks.

ENUM_MODE_UNCHANGED2Enumerate files with no changed blocks.

ENUM_MODE_LOCAL4Enumerate local files.

Refer to the Local Files topic for more information.

ENUM_MODE_ORPHAN8Enumerate orphan files.

Refer to the Orphan Files topic for more information.

ENUM_MODE_PINNED16Enumerate pinned files.

This method returns a handle that can be passed to the get_next_enumerated_file method to retrieve the results of the enumeration. If no matching files are found, -1 is returned instead.

When an application is finished enumerating files, it must call the close_enumeration method to release the associated resources.

file_change_id Method

This method changes the Id of a cached file.

Syntax

def file_change_id(file_id: str, new_file_id: str) -> None: ...

Remarks

This method changes the Id of the cached file identified by FileId to NewFileId. Applications that use file paths as Ids may need to use this method if a path element is renamed.

This method fails with an error if no file with the specified FileId is present in the cache, or if another file is already present in the cache with NewFileId.

file_close Method

This method closes a cached file.

Syntax

def file_close(file_id: str) -> None: ...

Remarks

This method closes the cached file identified by FileId, performing any of the flushing and/or purging operations specified by the class's other properties. (To override the configured flushing and purging behaviors, use the file_close_ex method instead.)

This method returns immediately, and any flushing and/or purging operations are performed in the background.

file_close_ex Method

This method closes a cached file, specifying flushing and purging behaviors explicitly.

Syntax

def file_close_ex(file_id: str, flush_action: int, purge_action: int) -> None: ...

Remarks

This method closes the cached file identified by FileId, performing any flushing and/or purging operations specified by the FlushAction and PurgeAction parameters.

The FlushAction parameter must be passed by one of the following values:

FLUSH_DELAYED0Flush as usual, taking into account any specified delay.

The flush_after_close_delay property specifies the delay. Passing this value to file_close or file_close_ex will cause the method to return immediately; flushing is performed in the background. Passing this value to close_cache has no effect (i.e., the cache is not flushed before being closed).

FLUSH_NONE1Do not flush anything.

FLUSH_IMMEDIATE2Flush immediately.

Passing this value to file_close, file_close_ex, and close_cache will cause the method to return only after all flushing operations are complete.

Note: Passing FLUSH_NONE will cause all background reading and writing threads for the file (if any) to be stopped.

The PurgeAction parameter must be passed by one of the following values:

PURGE_DELAYED0Purge as usual, taking into account any specified delay.

The purge_after_close_delay property specifies the delay. Passing this value to file_close or file_close_ex will cause the method to return immediately; purging is performed in the background. Passing this value to close_cache has no effect; the cache is not purged before being closed.

PURGE_NONE1Do not purge anything.

PURGE_IMMEDIATE2Purge immediately.

Passing this value to file_close, file_close_ex, or close_cache will cause the method to return only after all purging operations are complete.

This method returns immediately, and any flushing and/or purging operations are performed in the background.

file_delete Method

This method deletes a file from the cache.

Syntax

def file_delete(file_id: str) -> None: ...

Remarks

This method deletes the cached file identified by FileId, removing all of its data from the cache. If the specified file is currently open, it is closed first.

Note: The specified file is not flushed to external storage before being deleted; any unflushed data will be lost.

file_exists Method

This method checks if a file with the given Id is present in the cache.

Syntax

def file_exists(file_id: str) -> bool: ...

Remarks

This method checks to see whether a file with the specified FileId is present in the cache; returning True if so or False otherwise.

file_flush Method

This method flushes the specified file's modified blocks out to external storage.

Syntax

def file_flush(file_id: str, flush_mode: int, delay: int, file_context: int) -> int: ...

Remarks

This method flushes any modified data blocks for the file specified by FileId out to external storage via the on_write_data event (and possibly, the on_read_data event, if the cache is forced to retrieve data from external storage before writing it back). The FlushMode parameter specifies what kind of flushing should be performed. It must take one of the following values:

FLUSH_MODE_SYNC0Flush file data synchronously, blocking until finished.

FLUSH_MODE_ASYNC1Flush file data in the background; do not wait until the flush operation completes.

FLUSH_MODE_TEST2Check to see if file data exists and needs to be flushed, but do not actually flush anything.

The Delay parameter may be passed a non-zero number of seconds to delay the flushing operation.

The FileContext parameter may be passed any application-defined value. If the flushing operation causes the file to be opened, the specified value will be passed through to the on_write_data and on_read_data events' corresponding parameter. (If the file is already open, the value passed to file_open takes precedence).

This method will return one of the following values:

FLUSH_RESULT_NOTHING0The file has no data that need flushing.

FLUSH_RESULT_DIRTY1Data in the file need flushing, but no flush operation is running yet.

FLUSH_RESULT_RUNNING2Data in the file are in the process of being flushed.

FLUSH_RESULT_SUCCESS3Data in the file have been flushed successfully.

file_get_pinned Method

This method returns the pinned state of a cached file.

Syntax

def file_get_pinned(file_id: str) -> bool: ...

Remarks

This method indicates whether the cached file identified by FileId is pinned (or reports an error if no such file is present in the cache).

Pinned files are the files whose data are not purged automatically. If you need to remove the local data of a pinned file, use the file_purge method.

file_get_size Method

This method gets the "real size" of a cached file.

Syntax

def file_get_size(file_id: str) -> int: ...

Remarks

This method returns the application-reported File Sizes for the cached file identified by FileId (or reports an error if no such file is present in the cache).

Note: The size value returned by this method is the one previously set by the application through the file_open or file_set_size method; it does not necessarily correspond to the actual amount of data present in the cache for the file.

file_get_status Method

This method gets the status of a cached file.

Syntax

def file_get_status(file_id: str, status_kind: int) -> bool: ...

Remarks

This method returns the status of the cached file identified by FileId (or reports an error if no such file is present in the cache). StatusKind must be one of the following:

FILE_STATUS_CHANGED1Retrieves the value of the Changed state of the file.

FILE_STATUS_UNCHANGED2Retrieves the value of the Unchanged state of the file.

FILE_STATUS_LOCAL3Retrieves the value that indicates whether the file is Local.

Refer to the Local Files topic for more information.

FILE_STATUS_ORPHAN4Retrieves the value that indicates whether the file is Orphan.

Refer to the Orphan Files topic for more information.

FILE_STATUS_OPEN5Retrieves the value of the Open state of the file.

file_open Method

This method opens the specified cached file, creating it if necessary.

Syntax

def file_open(file_id: str, real_file_size: int, prefetch_size: int, file_context: int) -> None: ...

Remarks

This method opens the cached file identified by FileId, creating it if necessary.

The RealFileSize parameter informs the cache of the File Sizes (in bytes) of the real file (i.e., the one in external storage); this size can be changed later using the file_set_size method. For existing cached files, -1 may be passed to instruct the cache to use the previously set real file size instead.

The PrefetchSize parameter specifies how many bytes of data the cache should prefetch, from external storage, for the file via the on_read_data event (which will fire on a background thread). Pass PREFETCH_ALL to prefetch the entire fire, or PREFETCH_NOTHING to prefetch none of it.

The FileContext may be passed to any application-defined value; this value will then be passed through to any on_read_data and on_write_data events fired for the file.

file_open_ex Method

This method opens the specified cached file, creating it if necessary.

Syntax

def file_open_ex(file_id: str, real_file_size: int, is_local: bool, read_block_size: int, write_block_size: int, prefetch_size: int, file_context: int) -> None: ...

Remarks

This method opens the cached file identified by FileId, creating it if necessary.

The RealFileSize parameter informs the cache of the File Sizes (in bytes) of the real file (i.e., the one in external storage); this size can be changed later using the file_set_size method. For existing cached files, -1 may be passed to instruct the cache to use the previously set real file size instead.

The IsLocal parameter specifies whether the file is a local to the cache and does not exist in external storage; refer to the Local Files topic for more information.

ReadBlockSize and WriteBlockSize parameters make it possible for the application to configure the size of the block for reading and writing, respectively, thus overriding the values specified in the read_block_size and write_block_size properties for a specific file. Set the parameter to 0 to make the class use the value from the corresponding property. The values of the parameters will be used when reading_capabilities or writing_capabilities properties indicate that reading or writing should be performed in blocks of a specific size (or when the whole file should be read or written using sequential block operations).

The PrefetchSize parameter specifies how many bytes of data the cache should prefetch, from external storage, for the file through the on_read_data event (which will fire on a background thread). Pass PREFETCH_ALL to prefetch the entire fire, or PREFETCH_NOTHING to prefetch none of it. This parameter is ignored if IsLocal is True.

The FileContext may be passed to any application-defined value; this value will then be passed through to any on_read_data and on_write_data events fired for the file.

file_purge Method

This method purges unmodified data from the cache.

Syntax

def file_purge(file_id: str) -> None: ...

Remarks

This method removes unmodified data from the cache.

Use file_purge with pinned files to free space or after the pinned attribute has been removed and you need to remove the data immediately.

file_read Method

This method reads the specified part of a cached file.

Syntax

def file_read(file_id: str, position: int, buffer: bytes, index: int, count: int) -> bool: ...

Remarks

This method reads data from the cached file identified by FileId into the specified Buffer. The cached file must be opened using file_open before it can be read from.

Count bytes of data will be read from the cached file, starting from the specified Position, into the given Buffer. The data are written to Buffer starting at the given Index.

The method returns False if any errors happened during reading and returns True if everything went fine.

file_set_pinned Method

This method sets the pinned state of a cached file.

Syntax

def file_set_pinned(file_id: str, pinned: bool) -> None: ...

Remarks

This method specifies whether the cached file identified by FileId should be treated as pinned.

Pinned files are the files whose data are not purged automatically. If you need to remove the local data of a pinned file, use the file_purge method.

file_set_size Method

This method sets the "real size" of a cached file.

Syntax

def file_set_size(file_id: str, new_size: int, fetch_missing_data: bool) -> None: ...

Remarks

This method changes the "real size" of the cached file identified by FileId to the number of bytes specified by NewSize. The cached file must be opened using file_open before its real size can be changed.

ReadBlockSize and WriteBlockSize parameters make it possible for the application to configure the size of the block for reading and writing, respectively, thus overriding the values specified in the read_block_size and write_block_size properties for a specific file. Set the parameter to 0 to make the class use the value from the corresponding property. The values of the parameters will be used when reading_capabilities or writing_capabilities properties indicate that reading or writing should be performed in blocks of a specific size (or when the whole file should be read or written using sequential block operations).

The FetchMissingData parameter controls how the cache initializes new file space in cases in which the file's real size is increased. If FetchMissingData is True, the new file space is filled with real data fetched from external storage. Otherwise, the new file space is marked as zero-filled (although no actual data writing occurs).

file_set_size_ex Method

This method sets the "real size" of a cached file.

Syntax

def file_set_size_ex(file_id: str, new_size: int, read_block_size: int, write_block_size: int, fetch_missing_data: bool) -> None: ...

Remarks

This method changes the "real size" of the cached file identified by FileId to the number of bytes specified by NewSize. The cached file must be opened using file_open before its real size can be changed.

ReadBlockSize and WriteBlockSize parameters make it possible for the application to configure the size of the block for reading and writing, respectively, thus overriding the values specified in the read_block_size and write_block_size properties for a specific file. Set the parameter to 0 to make the class use the value from the corresponding property. The values of the parameters will be used when reading_capabilities or writing_capabilities properties indicate that reading or writing should be performed in blocks of a specific size (or when the whole file should be read or written using sequential block operations).

The FetchMissingData parameter controls how the cache initializes new file space in cases in which the file's real size is increased. If FetchMissingData is True, the new file space is filled with real data fetched from external storage. Otherwise, the new file space is marked as zero-filled (although no actual data writing occurs).

file_tag_delete Method

This method deletes a file tag.

Syntax

def file_tag_delete(file_id: str, tag_id: int) -> None: ...

Remarks

This method deletes the file tag identified by TagId from the cached file specified by FileId.

Please refer to the File Tags topic for more information.

Note: This method can be called only when active is True, and it cannot be called within events.

file_tag_exists Method

This method checks whether or not a file has a specific tag associated with it.

Syntax

def file_tag_exists(file_id: str, tag_id: int) -> bool: ...

Remarks

This method returns True if a file identified by FileId has an associated tag identified by TagId; otherwise, it returns False.

The value passed for TagId must be in the range from 0x0001 to 0xCFFF (inclusive).

Please refer to the File Tags topic for more information.

Note: This method can be called only when active is True, and it cannot be called within events.

file_tag_get Method

This method retrieves the binary data held by a file tag attached to the specified cached file.

Syntax

def file_tag_get(file_id: str, tag_id: int) -> bytes: ...

Remarks

This method retrieves the binary data stored in a file tag, identified by TagId attached to the file identified by FileId. If a file tag with the specified TagId is not attached to the specified file, this method raises an exception.

The value passed for TagId must be in the range from 0x0001 to 0xCFFF (inclusive).

Please refer to the File Tags topic for more information.

Note: This method can be called only when active is True, and it cannot be called within events.

file_tag_get_size Method

This method retrieves the size of a file tag attached to the specified cached file.

Syntax

def file_tag_get_size(file_id: str, tag_id: int) -> int: ...

Remarks

This method retrieves the size of the binary data stored in a file tag, identified by TagId, attached to the cached file identified by FileId. If a file tag with the specified TagId is not attached to the specified file, this method returns 0 as the tag size.

The value passed for TagId must be in the range from 0x0001 to 0xCFFF (inclusive).

Please refer to the File Tags topic for more information.

Note: This method can be called only when active is True.

file_tag_set Method

This method attaches a file tag with binary data to the specified cached file.

Syntax

def file_tag_set(file_id: str, tag_id: int, data: bytes) -> None: ...

Remarks

This method attaches a file tag with binary data to the cached file identified by FileId using the specified TagId. If a file tag with the specified TagId is already attached to the specified file, it is replaced.

The value passed for TagId must be in the range from 0x0001 to 0xCFFF (inclusive).

The Data parameter specifies the raw binary data to store in the file tag; it may be up to 65531 bytes in length.

Please refer to the File Tags topic for more information.

Note: This method can be called only when active is True, and it cannot be called within events.

file_touch Method

This method touches a range of data in a cached file.

Syntax

def file_touch(file_id: str, position: int, count: int, flush: bool) -> None: ...

Remarks

This method touches a range of data in the cached file identified by FileId, thereby marking it as changed and in need of flushing. The range of data to be touched starts at the specified Position and extends for Count bytes.

The cache will automatically attempt to read in any unavailable data in the touched range via on_read_data, and then will write out all data in the touched range via on_write_data. If the Flush parameter is True, these operations will take place synchronously and block return of this method; otherwise, they will take place in the background and this method will return immediately.

file_write Method

This method writes the specified part of a cached file.

Syntax

def file_write(file_id: str, position: int, buffer: bytes, index: int, count: int) -> bool: ...

Remarks

This method writes data to the cached file identified by FileId from the specified Buffer. The cached file must be opened using file_open before it can be written to.

Count bytes of data will be read from the given Buffer, starting at the given Index, and written into the cached file. The data are written to the cached file starting at the given Position.

If any amount of data is written beyond the known file size, such writing causes the file to grow unless the RWCAP_WRITE_NOT_BEYOND_EOF flag is specified. When the file grows, the known file size value for the file is updated and all the data are eventually flushed (written) to the external storage via the on_write_data event. The RWCAP_WRITE_NOT_BEYOND_EOF flag indicates that no writing should occur beyond the known file size, thus preventing the file from growth.

The method returns False if any errors happened during writing and returns True if everything went fine.

get_next_enumerated_file Method

This method returns the next file in the list of enumeration results.

Syntax

def get_next_enumerated_file(enumeration_handle: int) -> str: ...

Remarks

This method returns the Id of the next file in the list of enumeration results identified by the EnumerationHandle parameter. If the list does not have any more files, an empty string is returned.

When an empty string is returned because the end of the list has been reached, the class will close the enumeration automatically by calling close_enumeration. If the application finishes enumeration without reaching the end of the list, it must call the close_enumeration method to release any associated resources.

open_cache Method

This method opens the cache.

Syntax

def open_cache(encryption_password: str, case_sensitive: bool) -> None: ...

Remarks

This method opens the cache specified by the cache_file property; creating a storage file for it in the directory specified by the cache_directory property, if necessary.

To encrypt the cache, pass a nonempty string for the EncryptionPassword parameter the first time it is created. The same value will need to be passed any time the cache is opened again in the future.

If the StoreDataInFiles configuration setting is enabled, encryption affects only the main cache storage file and not the files that are used to store individual files' data.

The CaseSensitive parameter specifies whether the cache should treat its File Ids as case-sensitive or case-insensitive.

refresh_statistics Method

This method forces a refresh of the cache's statistics.

Syntax

def refresh_statistics() -> None: ...

Remarks

This method forces the cache to immediately refresh its statistics. The refreshed statistics will be reported through the on_status event and will be used to update the stats property.

This method needs to be called only if the applications needs to update the cache's statistics sooner than the end of the current StatsRefreshInterval.

reset_error_state Method

This method resets any outstanding errors for a file or external storage.

Syntax

def reset_error_state(file_id: str) -> None: ...

Remarks

If FileId is specified, this method resets any outstanding file errors, related to the cached file identified by FileId, previously reported via on_read_data and/or on_write_data events, thus allowing operations on the file to continue. If there are no outstanding errors for the specified file, this method does nothing.

If FileId is empty, this method resets any outstanding external-storage-related error previously reported via a on_read_data or on_write_data event, thus allowing external I/O operations to continue. If there are no outstanding external storage errors, this method does nothing.

start_cleanup Method

This method starts a background cleanup operation to remove unused files from the cache.

Syntax

def start_cleanup(max_age: int) -> None: ...

Remarks

This method starts a cleanup operation to remove unused files from the cache. Files used earlier than MaxAge hours ago will be removed (passing 0 will cause all files to be removed).

The cleanup operation is performed asynchronously in a background thread, so this method returns immediately. To cancel a cleanup operation, use the cancel_cleanup method.

on_before_flush Event

This event fires to report the start of the asynchronous file flush procedure.

Syntax

class CBCacheBeforeFlushEventParams(object):
  @property
  def file_id() -> str: ...

  @property
  def file_context() -> int: ...

  @property
  def last_use_time() -> datetime.datetime: ...

  @property
  def postpone_time() -> int: ...
  @postpone_time.setter
  def postpone_time(value) -> None: ...

# In class CBCache:
@property
def on_before_flush() -> Callable[[CBCacheBeforeFlushEventParams], None]: ...
@on_before_flush.setter
def on_before_flush(event_hook: Callable[[CBCacheBeforeFlushEventParams], None]) -> None: ...

Remarks

This event fires when the asynchronous file flush procedure starts for the cached file identified by FileId. This event does not fire if the flush procedure is initiated by the application using file_flush, file_close, or file_close_ex methods.

Note: This event will fire in the context of a dedicated worker thread that performs cache maintenance. Keep handling of this event as quick as possible.

Use the PostponeTime parameter to specify time in seconds to postpone automatic flush operation for this file.

on_before_purge Event

This event fires to report the start of the asynchronous file purge procedure.

Syntax

class CBCacheBeforePurgeEventParams(object):
  @property
  def file_id() -> str: ...

  @property
  def file_context() -> int: ...

  @property
  def last_use_time() -> datetime.datetime: ...

  @property
  def postpone_time() -> int: ...
  @postpone_time.setter
  def postpone_time(value) -> None: ...

# In class CBCache:
@property
def on_before_purge() -> Callable[[CBCacheBeforePurgeEventParams], None]: ...
@on_before_purge.setter
def on_before_purge(event_hook: Callable[[CBCacheBeforePurgeEventParams], None]) -> None: ...

Remarks

This event fires when the asynchronous file purge procedure starts for the cached file identified by FileId. This event does not fire if the purge procedure is initiated by the application using the file_flush, file_close, or file_close_ex methods.

Note: This event will fire in the context of a dedicated worker thread that performs cache maintenance. Keep handling of this event as quick as possible.

Use the PostponeTime parameter to specify time in seconds to postpone automatic purge operation for this file.

on_end_cleanup Event

This event fires to report the beginning of the asynchronous cleanup procedure.

Syntax

class CBCacheEndCleanupEventParams(object):
# In class CBCache:
@property
def on_end_cleanup() -> Callable[[CBCacheEndCleanupEventParams], None]: ...
@on_end_cleanup.setter
def on_end_cleanup(event_hook: Callable[[CBCacheEndCleanupEventParams], None]) -> None: ...

Remarks

This event fires when the asynchronous cleanup procedure ends.

Note: This event will fire in the context of a dedicated worker thread that performs cache maintenance. Keep handling of this event as quick as possible.

on_error Event

This event fires if an unhandled error occurs during an event.

Syntax

class CBCacheErrorEventParams(object):
  @property
  def error_code() -> int: ...

  @property
  def description() -> str: ...

# In class CBCache:
@property
def on_error() -> Callable[[CBCacheErrorEventParams], None]: ...
@on_error.setter
def on_error(event_hook: Callable[[CBCacheErrorEventParams], None]) -> None: ...

Remarks

This event fires if an unhandled error occurs during another event. Developers can use this information to track down unhandled errors in an application's event handlers.

IMPORTANT: Not everything is possible or allowed in the event handlers. Please see the Event Handling topic for details.

on_log Event

This log reports events that occur in the class.

Syntax

class CBCacheLogEventParams(object):
  @property
  def level() -> int: ...

  @property
  def message() -> str: ...

# In class CBCache:
@property
def on_log() -> Callable[[CBCacheLogEventParams], None]: ...
@on_log.setter
def on_log(event_hook: Callable[[CBCacheLogEventParams], None]) -> None: ...

Remarks

This event fires when the class needs to notify an application or developers about something that happened internally. The verbosity is controlled by the LogLevel setting.

LogLevel indicates the level of the message. Possible values are as follows:

0 (None) No information is logged.
1 (Errors) Only errors are logged.
2 (Warnings) Errors and warnings are logged.
3 (Information - Default) Errors, warnings, and informational messages are logged.
4 (Debug) Debug data are logged.

Message is the log entry.

Note: This event will fire in the context of a dedicated worker thread. Keep handling of this event as quick as possible.

on_progress Event

This event fires to report the progress of an operation.

Syntax

class CBCacheProgressEventParams(object):
  @property
  def operation() -> int: ...

  @property
  def current() -> int: ...

  @property
  def total() -> int: ...

  @property
  def interrupt() -> bool: ...
  @interrupt.setter
  def interrupt(value) -> None: ...

# In class CBCache:
@property
def on_progress() -> Callable[[CBCacheProgressEventParams], None]: ...
@on_progress.setter
def on_progress(event_hook: Callable[[CBCacheProgressEventParams], None]) -> None: ...

Remarks

This event fires when the cache wants to report the progress of the operation specified by Operation. Possible values are as follows:

CACHE_PO_CLEANUP1Cache cleanup

The Current and Total parameters specify the number of the item being processed, and the total number of items being processed, respectively. For some operations, these parameters may be 0 or -1.

The Interrupt parameter can be set to True to stop the operation.

on_read_data Event

This event fires when the cache needs to read file data from external storage.

Syntax

class CBCacheReadDataEventParams(object):
  @property
  def file_id() -> str: ...

  @property
  def size() -> int: ...

  @property
  def position() -> int: ...

  @property
  def flags() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def bytes_to_read() -> int: ...

  @property
  def bytes_read() -> int: ...
  @bytes_read.setter
  def bytes_read(value) -> None: ...

  @property
  def file_context() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBCache:
@property
def on_read_data() -> Callable[[CBCacheReadDataEventParams], None]: ...
@on_read_data.setter
def on_read_data(event_hook: Callable[[CBCacheReadDataEventParams], None]) -> None: ...

Remarks

This event fires when the cache needs to read data for the cached file identified by FileId from an external storage.

The Size parameter reflects the specified file's "real size" as it is currently known by the cache.

The Position parameter reflects the byte offset in the real file (i.e., the one in the external storage) from which the handler should start reading data.

The Flags parameter provides supplementary information about the nature of the request. This parameter, along with the Size and Position parameters, helps the event handler to determine, which part of the file Buffer represents and whether additional on_read_data events should be expected. It will include a combination of one or more of the following flags:

RWEVENT_IN_PROGRESS0x00000001A file's data are being transferred into or out of the cache.

RWEVENT_CANCELED0x00000002A data transfer has been canceled for some reason.

RWEVENT_WHOLE_FILE0x00000004The entire file is being transferred.

RWEVENT_CONTINUOUS_STARTED0x00000010A continuous transfer has started.

RWEVENT_CONTINUOUS_RESTARTED0x00000020A continuous transfer has restarted from the beginning.

RWEVENT_CONTINUOUS_FINISHED0x00000040A continuous transfer is finishing (i.e., the current block is the final one).

RWEVENT_RANDOM_STARTED0x00000100A random-access transfer has started.

RWEVENT_RANDOM_FINISHED0x00000200A random-access transfer is finishing (i.e., the current block is the final one).

RWEVENT_BEFORE_END0x00001000The current transfer will finish before the end of the file.

RWEVENT_TIL_END0x00002000The current transfer will last until the end of the file.

To handle this event property, a handler must read BytesToRead bytes of data from the real file in external storage, starting at the specified Position, into Buffer.

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Note: If Flags contains RWEVENT_CANCELED, the transfer is being canceled and no data should be read; the Buffer is not provided and both Position and BytesToRead parameters are set to 0.

When reading is complete, a handler must set BytesRead to reflect the actual number of bytes read from the real file. A handler must not attempt to copy more than BytesToRead bytes of data into Buffer.

The FileContext parameter reflects the application-defined value passed when file_open was called.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available, security checks failed), set it to one of the following values to report an appropriate error:

RWRESULT_SUCCESS0x00000000Success.

Returning this code indicates that all data were successfully transferred.

RWRESULT_PARTIAL0x00000080Partial success.

Returning this code indicates that some, but not all, data were successfully transferred. i.e., when BytesRead < BytesToRead (for on_read_data), or BytesWritten < BytesToWrite (for on_write_data).

RWRESULT_RANGE_BEYOND_EOF0x00000081Specified range is beyond the end of the file (EOF).

For the on_read_data event, returning this code indicates to the cache that there is no need to request data beyond (Position + BytesRead), and that the tail should be zeroed instead.

RWRESULT_FILE_MODIFIED_EXTERNALLY0x00000082The specified file's size was modified externally.

Returning this code indicates that the operation was not completed successfully because of this conflicting situation.

RWRESULT_FILE_MODIFIED_LOCALLY0x00000083The requested file's size was modified locally.

RWRESULT_FAILURE0x0000008DThe operation failed for some transient reason.

Returning this code indicates that, even though the current request failed, it is safe to continue sending requests for both the specified file and others. (Other operations may continue.)

RWRESULT_FILE_FAILURE0x0000008EThe operation failed for some external-file-related reason.

Returning this code indicates that some failure related to the external file has occurred, and it is expected that any further requests made against that file will also fail. The class will not send any more requests for the specified file until the file-specific error is reset as described in Reporting Transfer Errors.

RWRESULT_PERMANENT_FAILURE0x0000008FThe operation failed for some external-storage-related reason.

Returning this code indicates that some failure related to the external storage has occurred, and it is expected that all further requests will also fail. The class will not send any more requests for any file until the global error is reset as described in Reporting Transfer Errors.

Please refer to the Error Reporting and Handling topic for more information.

on_start_cleanup Event

This event fires to report the beginning of the asynchronous cleanup procedure.

Syntax

class CBCacheStartCleanupEventParams(object):
# In class CBCache:
@property
def on_start_cleanup() -> Callable[[CBCacheStartCleanupEventParams], None]: ...
@on_start_cleanup.setter
def on_start_cleanup(event_hook: Callable[[CBCacheStartCleanupEventParams], None]) -> None: ...

Remarks

This event fires when the asynchronous cleanup procedure starts.

Note: This event will fire in the context of a dedicated worker thread that performs cache maintenance. Keep handling of this event as quick as possible.

on_status Event

This event fires to report the latest cache statistics.

Syntax

class CBCacheStatusEventParams(object):
  @property
  def cache_size() -> int: ...

  @property
  def total_data() -> int: ...

  @property
  def unflushed_data() -> int: ...

  @property
  def unflushed_files() -> int: ...

  @property
  def current_operation() -> int: ...

  @property
  def current_file_id() -> str: ...

# In class CBCache:
@property
def on_status() -> Callable[[CBCacheStatusEventParams], None]: ...
@on_status.setter
def on_status(event_hook: Callable[[CBCacheStatusEventParams], None]) -> None: ...

Remarks

This event fires once every StatsRefreshInterval to provide the application with the latest cache statistics, as well as information about any in-progress cache operation.

The CacheSize parameter reflects the current size of the cache, in bytes.

The TotalData parameter reflects the total amount of data present in the cache, in bytes.

The UnflushedData parameter reflects the amount of unflushed data present in the cache, in bytes.

The UnflushedFiles parameter reflects the number of unflushed files present in the cache.

The CurrentOperation parameter reflects the cache's current operations; it will take one of the following values:

CACHE_OP_IDLE0The cache is idle.

CACHE_OP_CLEANUP2Cache cleanup is being performed.

CACHE_OP_COMPACT3The cache's storage file is being compacted.

CACHE_OP_READ4The cache is reading some file's data.

CACHE_OP_WRITE5The cache is writing some file's data.

When CurrentOperation is CACHE_OP_READ or CACHE_OP_WRITE, the CurrentFileId parameter will reflect the Id of the cached file being processed.

Note: This event can fire in the context of any thread.

on_write_data Event

This event fires when the cache needs to write file data to external storage.

Syntax

class CBCacheWriteDataEventParams(object):
  @property
  def file_id() -> str: ...

  @property
  def size() -> int: ...

  @property
  def position() -> int: ...

  @property
  def flags() -> int: ...

  @property
  def buffer() -> c_void_p: ...

  @property
  def bytes_to_write() -> int: ...

  @property
  def bytes_written() -> int: ...
  @bytes_written.setter
  def bytes_written(value) -> None: ...

  @property
  def file_context() -> int: ...

  @property
  def result_code() -> int: ...
  @result_code.setter
  def result_code(value) -> None: ...

# In class CBCache:
@property
def on_write_data() -> Callable[[CBCacheWriteDataEventParams], None]: ...
@on_write_data.setter
def on_write_data(event_hook: Callable[[CBCacheWriteDataEventParams], None]) -> None: ...

Remarks

This event fires when the cache needs to write data for the cached file identified by FileId to external storage.

The Size parameter reflects the specified file's "real size" as it is currently known by the cache.

The Position parameter reflects the byte offset in the real file (i.e., the one in external storage) at which the application should start writing data.

The Flags parameter provides supplementary information about the nature of the request. This parameter, along with the Size and Position parameters, helps the application to determine which part of the file Buffer represents, and whether additional on_write_data events should be expected. It will include a combination of one or more of the following flags:

RWEVENT_IN_PROGRESS0x00000001A file's data are being transferred into or out of the cache.

RWEVENT_CANCELED0x00000002A data transfer has been canceled for some reason.

RWEVENT_WHOLE_FILE0x00000004The entire file is being transferred.

RWEVENT_CONTINUOUS_STARTED0x00000010A continuous transfer has started.

RWEVENT_CONTINUOUS_RESTARTED0x00000020A continuous transfer has restarted from the beginning.

RWEVENT_CONTINUOUS_FINISHED0x00000040A continuous transfer is finishing (i.e., the current block is the final one).

RWEVENT_RANDOM_STARTED0x00000100A random-access transfer has started.

RWEVENT_RANDOM_FINISHED0x00000200A random-access transfer is finishing (i.e., the current block is the final one).

RWEVENT_BEFORE_END0x00001000The current transfer will finish before the end of the file.

RWEVENT_TIL_END0x00002000The current transfer will last until the end of the file.

To handle this event properly, applications must write BytesToWrite bytes of data from Buffer to the real file in external storage, starting at the specified Position.

Please see the Buffer Parameters topic for more information on how to work with memory buffer event parameters.

Note: If Flags contains RWEVENT_CANCELED, the transfer is being canceled and no data should be written; the Buffer is not provided and both Position and BytesToWrite parameters are set to 0.

When writing is complete, applications must set BytesWritten to reflect the actual number of bytes written to the real file. Applications must not attempt to copy more than BytesToWrite bytes of data from Buffer.

The FileContext parameter reflects the application-defined value passed when file_open was called.

The ResultCode parameter will always be 0 when the event is fired. If the event cannot be handled in a "successful" manner for some reason (e.g., a resource is not available, security checks failed), set it to one of the following values to report an appropriate error:

RWRESULT_SUCCESS0x00000000Success.

Returning this code indicates that all data were successfully transferred.

RWRESULT_PARTIAL0x00000080Partial success.

Returning this code indicates that some, but not all, data were successfully transferred. i.e., when BytesRead < BytesToRead (for on_read_data), or BytesWritten < BytesToWrite (for on_write_data).

RWRESULT_RANGE_BEYOND_EOF0x00000081Specified range is beyond the end of the file (EOF).

For the on_read_data event, returning this code indicates to the cache that there is no need to request data beyond (Position + BytesRead), and that the tail should be zeroed instead.

RWRESULT_FILE_MODIFIED_EXTERNALLY0x00000082The specified file's size was modified externally.

Returning this code indicates that the operation was not completed successfully because of this conflicting situation.

RWRESULT_FILE_MODIFIED_LOCALLY0x00000083The requested file's size was modified locally.

RWRESULT_FAILURE0x0000008DThe operation failed for some transient reason.

Returning this code indicates that, even though the current request failed, it is safe to continue sending requests for both the specified file and others. (Other operations may continue.)

RWRESULT_FILE_FAILURE0x0000008EThe operation failed for some external-file-related reason.

Returning this code indicates that some failure related to the external file has occurred, and it is expected that any further requests made against that file will also fail. The class will not send any more requests for the specified file until the file-specific error is reset as described in Reporting Transfer Errors.

RWRESULT_PERMANENT_FAILURE0x0000008FThe operation failed for some external-storage-related reason.

Returning this code indicates that some failure related to the external storage has occurred, and it is expected that all further requests will also fail. The class will not send any more requests for any file until the global error is reset as described in Reporting Transfer Errors.

Please refer to the Error Reporting and Handling topic for more information.

CBCache Config Settings

The class accepts one or more of the following configuration settings. Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the class, access to these internal properties is provided through the config method.

CBCache Config Settings

BlockSize:   The size of the block, used to store the data.

This read-only configuration setting returns the size of the block, used by the cache to store and transfer the data. The initial value is 0. It is recalculated depending on the capabilities of the application and the supported size of the reading and writing blocks.

JournalingMode:   Specifies whether the main cache file uses journaling for increased data consistency.

This configuration setting specifies whether the filesystem behind the main cache file should use journaling for metadata and main file data. Possible values are:

VAULT_JM_NONE0No journaling is used.

This mode ensures the fastest operations, but if the application crashes, corruption of the vault is possible.

VAULT_JM_METADATA1Journaling is used only for metadata (filesystem structure and directory contents).

This mode is a balance between speed and reliability.

VAULT_JM_FULL2Journaling is used for both filesystem structure and file data and metadata.

This mode is the slowest but the most reliable option.

LogLevel:   The level of detail that is logged.

This configuration setting controls the level of detail that is logged through the on_log event. Possible values are as follows:

0 (None) No information is logged.
1 (Errors) Only errors are logged.
2 (Warnings) Errors and warnings are logged.
3 (Information - Default) Errors, warnings, and informational messages are logged.
4 (Debug) Debug data are logged.

MaxReaderThreadsPerFile:   The maximum number of reader threads to use to fire events.

This configuration setting specifies the maximum number of reader threads per file the class may create to fire events when the serialization property is set to smPerFileReadingWritingConcurrent value.

By default, this configuration setting is set to 4 threads per file.

StatsRefreshInterval:   Minimum time period between cache statistics refreshes.

This configuration setting specifies the minimum time period, in milliseconds, between automatic cache statistics refreshes. Each statistics refresh causes the on_status event to fire and updates the values in the stats property.

The statistics refresh interval is intended to prevent excessive user interface changes. Set the value to 0 to disable automatic refresh. The default value is 100 ms.

Note: Applications may call refresh_statistics at any time to explicitly refresh the cache's statistics.

StoreDataInFiles:   Specifies whether file data should be stored in the main cache file or in individual files.

When this configuration setting is disabled (default), the cache stores all data in one file with encryption and compression applied (when they are enabled through the corresponding properties).

When this configuration setting is enabled, the cache stores individual files' data in separate files and uses the main cache file to store various metadata. This option makes the main cache file smaller and opening of the cache file becomes faster. Also, the speed of intensive write operations of large files is increased. The cache in this mode, however, does not provide encryption or compression of file data and journaling of file data does not take place either.

Base Config Settings

BuildInfo:   Information about the product's build.

When queried, this setting will return a string containing information about the product's build.

LicenseInfo:   Information about the current license.

When queried, this setting will return a string containing information about the license this instance of a class is using. It will return the following information:

  • Product: The product the license is for.
  • Product Key: The key the license was generated from.
  • License Source: Where the license was found (e.g., RuntimeLicense, License File).
  • License Type: The type of license installed (e.g., Royalty Free, Single Server).

CBCache Errors

Cache errors Errors

0x48000001   ERROR_ALREADY_OPENED: The requested operation cannot be performed while the cache is open.
0x48000002   ERROR_NOT_OPENED: The cache must be open before attempting to perform the requested operation.
0x48000003   ERROR_REQ_PARAM_MISSING: The requested operation cannot be performed because a required property has not been set.
0x48000004   ERROR_WRONG_ARGUMENT: An invalid value has been passed for the method parameter specified in the error message.
0x48000005   ERROR_BACKEND_FAILURE: The cache cannot read data from or write data to external storage because an event handler has reported an error. Once the error state has been reset using reset_error_state, try again.
0x48000006   ERROR_BACKEND_FILE_FAILURE: The cache cannot read data from or write data to external storage because an event handler has reported a file error. Once the error state has been reset using reset_error_state, try again.
0x48000007   ERROR_INVALID_OPERATION: The requested operation is not valid in current context. Refer to the error message for additional information.
0x48000008   ERROR_STORAGE_FAILURE: An operation involving the cache storage file has failed.
0x48000009   ERROR_WRONG_ENCRYPTION_KEY: The specified cache encryption key is incorrect.
0x4800000A   ERROR_DIR_NOT_EMPTY: The cache has failed to delete all blocks from the cache storage file.
0x4800000B   ERROR_FILE_NOT_OPEN: The requested operation cannot be completed because the specified file is not open. Open it using file_open, and then try again.
0x4800000C   ERROR_PATH_NOT_FOUND: The requested operation cannot be completed because the specified path is not found.
0x4800000D   ERROR_FILE_NOT_FOUND: The requested operation cannot be completed because the specified file is not found.
0x4800000E   ERROR_FILE_ALREADY_EXISTS: The requested operation cannot be completed because the specified file already exists.
0x4800000F   ERROR_INVALID_FILE_STATE: The requested operation cannot be completed because the specified file is in an invalid state. Close it using file_close, and then try again.
0x48000010   ERROR_READWRITE_FAILURE: An operation of reading or writing the data from/to the cache has failed.
0x48000011   ERROR_OFFLINE: The requested operation cannot be completed because the external storage is offline.
0x48000012   ERROR_UNSUPPORTED: The specified combination of external storage capabilities is not supported by the cache. Please double-check that the reading_capabilities, writing_capabilities, and resizing_capabilities properties are set correctly.
0x48000013   ERROR_INTERNAL_OPERATION_CANCELED: The requested operation cannot be completed because it was canceled.
0x48000014   ERROR_INTERNAL_VAULT_CORRUPTED: The cache vault is corrupted. check_and_repair should be used to attempt to fix the vault.
0x48000015   ERROR_INTERNAL_VAULT_RECREATED: The cache vault has been corrupted beyond repair and has been recreated. This is not strictly an error but a nonplanned outcome.
0x49000001   ERROR_INTERNAL_ERROR_FIRST: An internal error has occurred. Please report the error details to the Callback Technologies support team.
0x4900000B   ERROR_INTERNAL_ERROR_LAST: An internal error has occurred. Please report the error details to the Callback Technologies support team.