Class: SharedObject

@include <SharedObject>

Base class for objects that can be used across multiple concurrent processes

This is an abstract class and should not be instantiated directly. It provides methods for locking, unlocking, and setting encryption. Subclasses should implement their own methods for reading and writing data.

Internally, it uses the file system to store the object’s state.

Methods

@SharedObject.setEncrypted

Scope: public

Set whether the object should be encrypted.

Encrypting the object can mitigate unauthorized reads by other processes. This flag cannot be changed after the object has been used.

Returns: 1 if the object has already been used or ‘openssl’ is unavailable, 0 otherwise.

Usage: @SharedObject.setEncrypted $value

Parameters

  • value
    • Type: Primitive
    • ‘1’ or ‘true’ enables encryption, any other value disables it.

@SharedObject.lock

Scope: public

Lock the shared object for exclusive access

Once locked, only the process which locked it can access the object until it is unlocked. Attempts by other processes to access the object will block until it is unlocked.

Returns: 1 if the lock could not be acquired, 0 otherwise.

Usage: @SharedObject.lock

@SharedObject.unlock

Scope: public

Unlock the shared object, allowing other processes to access it.

Returns: 1 if the object was not locked by this process, 0 otherwise.

Usage: @SharedObject.unlock