Home Features Demos Download Installation User Manual Developer Manual Relation function Credits

Login

inc/ramdisk.php

Caches can read files from a folder on a ramdisk, if the configuration provides a path to them.
The ramdisk must be created directly on the system. Make sure that PHP can write to the folder you specifiy. You provide a path to a folder on the ramdisk with $swRamdiskPath (trailing slash).

Actually, the following files are cached:

  • revisions
  • current
  • queries
  • bitmaps of indexes

urls.txt is not cached because they are written with random access which is not possible for PHP permissions.

Note that if the ramdisk is gone, the cached files are gone, too. However, the files on the harddisk still exist.

If there is less than 10 MB available, a bunch of 1000 cache files are randomly erased to make space.

If the Ramdisk is not available, it falls back to the normal folders in indexes.

Alternative Berkeley DB

If you cannot install a RAM disk, you can use the Berkeley DB to store copies of the revisions. The access to a file is about 2ms, while it is 25ms if you access it normally. This should speed up any kind of query and relation functions.

Set configuration.php
$swRamdiskPath = 'db';

Create a 1 GB Ramdisk

diskutil erasevolume HFS+ 'ramdisk' `hdiutil attach -nomount ram://2048000`

Functions

swInitRamdisk($path, $s)

swFileGet($path)


Wrapper function for file_get_contents() using cache if available and saving to cache if not.

swFileUnlink($path)


Wrapper function for unlink() deliberately removing the file from the cache, too.

swIndexRamDiskDB()


Indexes the Berkeley DB, if you use it instead of a RAM disk.

swUpdateRamDiskDB()


Updates RAM disk jobs (faster to do 50 at a time than to open DB each time for write).

File structure inc folder