The WebAbility® Network Developers - Documentation
WebAbility Site
\datasource\SHMSource reference

I. Structure:


- namespace:
\datasource\

- Direct superclass:
\datasource\DataSource

- Direct known subclasses:
none

II. Description:


This is the basic class to access a shared memory segment.

The constructor comes with 2 parameters: the $id is the variable entry into the shared memory and the object $SHM already created by your code.
If the variable $id exists into the shared memory, the object is valid.

The \datasource\SHMSource will NOT cache in memory the content of the variable. It is a 1-level read/write/unlink access only.

unlink will physically deletes the variable from the shared memory segment.


III. Reference:


3.1. Contructor:


\datasource\SHMSource($id, $SHM)
Creates the instance.
  • $id: string, the variable id to access the shared memory.
  • $SHM: WASHM instance, the instance of our shared memory to access.


3.2. Constants:

There is no constant into this class.


3.3. Attributes:


protected WASHM $SHM
Is used to store the shared memory instance.


3.4. Methods:


public boolean static isValid()
This method is used to know if the data into the shared memory is valid or not.
If the variable does not exists, the object is not valid. Otherwise it is valid.

public integer getTimeStamp()
This method is used to get the last write access to the variable into the shared memory.
If the object is invalid, it will return null.
Note: The returned value is a unix timestamp that you can format to a human readable date with date().

public mixed read()
This method is used to read the value of the variable into the shared memory.
If the object is invalid (variable does not exists), it will return null.

public void write($data)
This method is used to write the data into the shared memory.
  • $data: mixed, the data to write in the shared memory.

public void unlink()
This method is used to physically deletes the variable from the shared memory.
The object becomes invalid.