{
    "mode": "perldoc",
    "parameter": "Apache::Session::Lock::File",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Apache%3A%3ASession%3A%3ALock%3A%3AFile/json",
    "generated": "2026-07-05T09:32:34Z",
    "synopsis": "use Apache::Session::Lock::File;\nmy $locker = Apache::Session::Lock::File->new;\n$locker->acquirereadlock($ref);\n$locker->acquirewritelock($ref);\n$locker->releasereadlock($ref);\n$locker->releasewritelock($ref);\n$locker->releasealllocks($ref);\n$locker->clean($dir, $age);",
    "sections": {
        "NAME": {
            "content": "Apache::Session::Lock::File - Provides mutual exclusion using flock\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Apache::Session::Lock::File;\n\nmy $locker = Apache::Session::Lock::File->new;\n\n$locker->acquirereadlock($ref);\n$locker->acquirewritelock($ref);\n$locker->releasereadlock($ref);\n$locker->releasewritelock($ref);\n$locker->releasealllocks($ref);\n\n$locker->clean($dir, $age);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Apache::Session::Lock::File fulfills the locking interface of Apache::Session. Mutual exclusion\nis achieved through the use of temporary files and the \"flock\" function.\n",
            "subsections": []
        },
        "CONFIGURATION": {
            "content": "The module must know where to create its temporary files. You must pass an argument in the usual\nApache::Session style. The name of the argument is LockDirectory and its value is the path where\nyou want the lockfiles created. Example:\n\ntie %s, 'Apache::Session::Blah', $id, {LockDirectory => '/var/lock/sessions'}\n\nIf you do not supply this argument, temporary files will be created in /tmp.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "clean\nThis module does not unlink temporary files, because it interferes with proper locking. This can\ncause problems on certain systems (Linux) whose file systems (ext2) do not perform well with\nlots of files in one directory. To prevent this you should use a script to clean out old files\nfrom your lock directory. The meaning of old is left as a policy decision for the implementor,\nbut a method is provided for implementing that policy. You can use the \"clean\" method of this\nmodule to remove files unmodified in the last $age seconds. Example:\n\nmy $l = Apache::Session::Lock::File->new;\n$l->clean('/var/lock/sessions', 3600) #remove files older than 1 hour\n\nacquirereadlock\nWill do nothing if write lock is in effect, only set readlock flag to true.\n\nreleasereadlock\nWill do nothing if write lock is in effect, only set readlock flag to false.\n",
            "subsections": [
                {
                    "name": "Win32 and Cygwin",
                    "content": "Windows cannot escalate lock, so all locks will be exclusive.\n\nreleasereadlock not supported - it is not used by Apache::Session.\n\nWhen deleting files, they are not locked (Win32 only).\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "This module was written by Jeffrey William Baker <jwbaker@acm.org>.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Apache::Session\n",
            "subsections": []
        }
    },
    "summary": "Apache::Session::Lock::File - Provides mutual exclusion using flock",
    "flags": [],
    "examples": [],
    "see_also": []
}