@include <SharedStack>

The SharedStack class provides a stack implementation that shares its state across multiple instances. This class is useful for scenarios in which we’re forking processes and need a shared stack between them.

Reads and writes are atomic and concurrency-safe.

The stack can be encrypted for security.

Internally, it uses the file system to store the stack state.

Methods

@SharedStack.setEncrypted

Scope: public

Sets whether the stack should be encrypted. Encrypting the stack can mitigate unauthorized reads by other processes. This cannot be changed after the stack has been used.

Usage: @SharedStack.setEncrypted $value

Parameters

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

@SharedStack.size

Scope: public

Echoes the number of elements in the stack.

Usage: @SharedStack.size

@SharedStack.push

Scope: public

Pushes a value onto the top of the stack.

Usage: @SharedStack.push $value

Parameters

  • value
    • Type: primitive
    • The value to push onto the top of the stack.

@SharedStack.pop

Scope: public

Pops the top element off the stack and echoes it.

Usage: @SharedStack.pop

@SharedStack.top

Scope: public

Echoes the top element of the stack without removing it.

Usage: @SharedStack.top

@SharedStack.clear

Scope: public

Removes all elements from the stack.

Usage: @SharedStack.clear

@SharedStack.empty

Scope: public

Echoes “true” if the stack is empty, “false” otherwise.

Usage: @SharedStack.empty