Interface for a persistent object storage type provided by a worker.
When a worker is created, it initializes a new environment object, which is stored in memory that is local to that worker. When a worker executes a task, this persistent environment object is given to the task to use.
An environment is not destroyed until the worker that owns it is shut down.
Environment::exists(string $key): bool
Checks if a given key exists.
- The key to check.
True if the key exists, otherwise false.
Environment::get(string $key): mixed|null
- The key to get.
The value stored for the given key, or
null if the key does not exist.
Environment::set(string $key, mixed $value, int $ttl = 0)
Sets a key/value pair in the environment.
- The key to set.
- The value to set.
- Number of seconds until data is automatically deleted. Use 0 for unlimited TTL.
Deletes a value based on its key.
- The key to delete.
Gets the number of values in the environment.
Removes all values.Next: Worker\Pool