Back to the module list

Put anything in queue

This class allow to add entries in queue and read them later in FIFO or LIFO or global range.

The entries can be anything : string, array, integer...

Internally, the store is done in a file and each entry is recorded in JSON.

The class definition

Class Domframework\Queuefile

Namespace Domframework

Description

/**
 Manage a queue in file
 A process can add entries to the end of a queue
 A process can get all the entries in a queue
 A process can clear all the entries in a queue
 A process can get the first entry in the queue (FIFO), with optional
 removing of the entry
 A process can get the last entry in the queue (LIFO), with optional
 removing of the entry
 A process can get X entries starting at position Y

Properties

No property available

Methods

public function add ( $entry)
/**
 Add a new entry to the end of the queue
 @param mixed $entry The entry to add
 @return $this;

public function clear ()
/**
 Clear all the entries of the queue
 @return $this;

public function connect ( $dsn)
/**
 Connect to the queue. Create it if not exists
 @param string $dsn The DSN to connect to queue
 @return $this;

public function count ()
/**
 Get the number of entries in the queue

public function getAll ( $delete=false)
/**
 Get all the entries of the queue
 @param boolean|null $delete If true, delete the read entry
 @return array

public function getFirst ( $delete=false)
/**
 Get the first entry in the queue with optional removing of the entry
 @param boolean|null $delete If true, delete the read entry
 @return mixed Return null if there is no entry, or the first entry in the
 queue (FIFO)

public function getLast ( $delete=false)
/**
 Get the last entry in the queue with optional removing of the entry
 @param boolean|null $delete If true, delete the read entry
 @return mixed Return null if there is no entry, or the last entry in the
 queue (LIFO)

public function getRange ( $start, $number, $delete=false)
/**
 Get X entries starting at position Y
 @param integer $start the starting position (the entries start at position
 zero)
 @param integer $number The number of entries to get
 @param boolean|null $delete If true, delete the read entries
 @return array An array of mixed entries