Click or drag to resize
IDirectoryCache Interface
The interface for objects that can cache the filenames in a folder.

Namespace: VirtualRadar.Interface
Assembly: VirtualRadar.Interface (in VirtualRadar.Interface.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public interface IDirectoryCache : IDisposable

The IDirectoryCache type exposes the following members.

Properties
  NameDescription
Public propertyCacheSubFolders
Gets or sets a value indicating that sub-folders under Folder should also be cached.
Public propertyFolder
Gets or sets the folder whose content should be cached. Setting a new folder name erases the current cache and forces the caching on a background thread of the filesnames in the new folder.
Public propertyProvider
Gets or sets the object that abstracts away the environment for testing.
Top
Methods
  NameDescription
Public methodBeginRefresh
Starts an immediate refresh of the cache.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodGetFullPath
Takes a filename without a directory and returns the full path of the file in the cache.
Public methodSetConfiguration
Assigns both Folder and CacheSubFolders simultaneously. Returns true if the assignment triggered a refresh of the cache.
Top
Events
  NameDescription
Public eventCacheChanged
Raised on a background after the cache has been modified in some way. It is not raised if the content of the cache did not change.
Top
Remarks

This was written to cache the names of aircraft pictures in an aircraft picture folder. It was found that when the picture folder held several thousand aircraft the lookup times could be painful, so the program now uses this to cache the filenames in the folder.

The .NET FileSystemWatcher object was tested but was found to be unreliable when the aircraft picture folder was a network share, particularly when the network share was hosted on a non-Windows machine. So instead the implementation may employ a polling technique to fetch files. This can introduce the following problems:

  • New files may be reported as missing when they exist.
  • Deleted files may be reported as existing when they don't.

This is not a particular problem for the intended use of the cache as users are unlikely to delete aircraft pictures once they have them and missing a new file isn't the end of the world either. Making these kinds of mistakes will only lead to the possibility of very occasional website picture glitches. However it can make this cache unsuitable for more critical purposes.

The cache can detect the following changes between polls:

  • Files that have been added.
  • Files that have been removed.
  • Files that have been renamed*.
  • Files whose last modified time has changed.

It will not pick up changes to size, create time, access time or case. If the file is renamed but a new file matches the name of a file in the cache, and the renamed file has the same modified time as the cached file, and the old file is replaced with a new file that has the same modified time as the old file, then the rename will not be detected.

See Also