FileDependency

FileDependency

Tracks File dependencies to other objects in application's Cache.


Constructor

# new FileDependency(fileNames, startAfter)

Initializes a new instance of the FileExpiration class that monitors an array of file paths (to files or directories) for changes and indicates when change tracking is to begin

Parameters:
Name Type Description
fileNames Iterable.<String>

Array of dependent file paths.

startAfter Date

StartAfterTicks shows the time after which dependency is to be started.

Example
//Initialize the Cache Cluster 
let cache = await ncache.CacheManager.getCache("demoCache");

// Generate a json object of  customer
let customer = getCustomerObjuect();

// create CacheItem to with your desired object
let cacheItem = new ncache.CacheItem(customer, "Json");

// add file dependency to cacheItem
let fileDependency = new ncache.FileDependency("filePath");
cacheItem.setDependency(fileDependency);

// Adding item dependent on file 
await cache.add(customer.CustomerID, cacheItem);

//Any modification in the dependent file will cause invalidation of the dependent item.
   

Methods

# getFileNames() → {Array.<String>}

Get the array of file names

Returns:
Type
Array.<String>

# getStartAfterTicks() → {Number}

Get the tick

Returns:
Type
Number

# (async) initialize(fileNames, startAfter)

Initializes a FileExpiration that monitors an array of file paths (to files or directories) for changes and indicates when change tracking is to begin

Parameters:
Name Type Description
fileNames Iterable.<String>

Array of dependent file paths.

startAfter Date

StartAfterTicks shows the time after which dependency is to be started.