I’ve always liked the Virtual File System (VFS) implementation in ColdFusion, but I always griped about one thing. The files written to the VFS are available at the Server level and are not specific to an application. However, ColdFusion 10 now includes support for Application specific in-memory file system. This means that, if you write a file to the virtual file system, only those files in the same application can access it. If an attempt is made by another application to access this file, the server would happily throw an error.
Consider this example:
As you can see files in ‘App1’ can write and read from the virtual file system and when an external application (‘App2’) tries to read file, the server just says bugger off. Well not quite literally, it actually throws a FileNotFoundException.
By default, the in-memory file system is accessed at the server level. To enable this functionality two Application level settings are provided:
Consider this example:
As you can see files in ‘App1’ can write and read from the virtual file system and when an external application (‘App2’) tries to read file, the server just says bugger off. Well not quite literally, it actually throws a FileNotFoundException.
By default, the in-memory file system is accessed at the server level. To enable this functionality two Application level settings are provided:
component
{
this.name="App1";
this.inmemoryfilesystem.enabled = true;
this.inmemoryfilesystem.size = 4;
}
The setting this.inmemoryfilesystem.enabled = true enables application specific in-memory file system and you can also specify the size of this file system by setting this.inmemoryfilesystem.size with an appropriate value. You can also specify the size in ColdFusion Administrator by assigning a value to the field ‘Memory Limit per Application for In-Memory Virtual File System’ under Settings section. In a case where the size is specified at both the places – in Administrator as well as in Application.cfc the lesser of the two is considered.
Comments
Post a Comment