Apache-SharedMem

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        IPC::SysV. Process' UID and DOCUMENT_ROOT (or current working
        directory) are given to "ftok" so as to guarantee an unique key as
        far as possible.

        Note, if you are using mod_perl, and you'v load mod_perl via
        startup.pl (see USAGE section for more details), the rootkey is
        generated once at the apache start, based on the supplied
        PROJECT_DOCUMENT_ROOT and Apache's uid.

    *   "namespace" optional, string

        Setup manually the namespace. To share same datas, your program must
        use the same namespace. This namespace is set by default to the
        caller's package name. In most cases the default value is a good
        choice. But you may setup manually this value if, for example, you
        want to share the same datas between two or more modules.

    *   "ipc_mode" optional, octal

        Setup manually the segment mode (see the IPC::ShareLite manpage) for
        more details (default: 0600). Warning: this value _must_ be octal,
        see chmod documentation in perlfunc manpage for more details.

    *   "ipc_segment_size" optional, integer

        Setup manually the segment size (see the IPC::ShareLite manpage) for
        more details (default: 65_536).

    *   "debug" optional, boolean

        Turn on/off the debug mode (default: 0)

    In most case, you don't need to give any arguments to the constructor.

    "ipc_mode" and "ipc_segment_size" are used only on the first namespace
    initialisation. Using different values on an existing key (in shared
    memory) has no effect.

    Note that "ipc_segment_size" is default value of IPC::ShareLite, see the
    IPC::ShareLite manpage

    On succes return an Apache::SharedMem object, on error, return undef().
    You can get error string via $Apache::SharedMem::ERROR.

  get  (key, [wait, [timeout]])

    my $var = $object->get('mykey', WAIT, 50); if($object->status & FAILURE)
    { die("can't get key 'mykey´: " . $object->error); }

    *   "key" required, string

        This is the name of elemenet that you want get from the shared
        namespace. It can be any string that perl support for hash's key.

    *   "wait" optional

        Defined the locking status of the request. If you must get the
        value, and can't continue without it, set this argument to constant
        WAIT, unless you can set it to NOWAIT.

        If the key is locked when you are tring to get the value, NOWAIT
        return status FAILURE, and WAIT hangup until the value is unlocked.
        An alternative is to setup a WAIT timeout, see below.

        NOTE: you needs :wait tag import:

            use Apache::SharedMem qw(:wait)

        timeout (optional) integer:

        if WAIT is on, timeout setup the number of seconds to wait for a
        blocking lock, usefull for preventing dead locks.

    Following status can be set (needs :status tag import):

    SUCCESS FAILURE

    On error, method return undef(), but undef() is also a valid answer, so
    don't test the method status by this way, use ($obj->status & SUCCESS)
    instead.

  set  (key, value, [wait, [timeout]])

    my $rv = $object->set('mykey' => 'somevalue'); if($object->status eq
    FAILURE) { die("can't set key 'mykey´: " . $object->error); }

    Try to set element "key" to "value" from the shared segment.

    *   "key" required

        name of place where to store the value

    *   "value" required

        data to store

    *   "wait" optional

        WAIT or NOWAIT (default WAIT) make or not a blocking shared lock
        (need :wait tag import).

    *   "timeout" optional

        if WAIT is on, timeout setup the number of seconds to wait for a
        blocking lock (usefull for preventing dead locks)

    return status: SUCCESS FAILURE

  delete  (key, [wait, [timeout]])

  exists  (key, [wait, [timeout]])

  firstkey  ([wait, [timeout]])

  nextkey  (lastkey, [wait, [timeout]])

  clear ([wait, [timeout]])

    return 0 on error

  release [namespace]



( run in 0.791 second using v1.01-cache-2.11-cpan-5837b0d9d2c )