RSS 2.0
RSS 0.91
ATOM 0.3
April 29, 2010

4.3 Treasure Trove: the system registry

Category: Core

By: François Suter

TYPO3 4.3 is rich with new features. A lot of them didn't get the attention they deserved, in particular the very useful system registry.

The system registry is a simple table designed to store key-value pairs. This is not meant for heavy-duty storage, but just to store a couple of values, when having a separate database table is not warranted. A typical example is the Scheduler, which just needs to store information about its last run and not a full log.

The system registry can be used by any part of TYPO3 or any extension. The provided API makes it dead simple to use. Entries in the system registry are comprised of three parameters:

  • a namespace that helps making an entry unique
  • a key which identifies the entry
  • the value of the entry, which is stored as a BLOB in the database

To use the registry, start by getting an instance of it:

$registry = t3lib_div::makeInstance('t3lib_Registry');

You can then use the following methods:

  • set to create a new entry or update an existing one
  • get to retrieve an entry
  • remove to delete an entry
  • removeAllByNamespace to delete all entries for a given namespace

Here's a more complete example, taken from the Scheduler:

$registry = t3lib_div::makeInstance('t3lib_Registry');
$runInformation = array('start' => $GLOBALS['EXEC_TIME'], 'end' => time(), 'type' => $type);
$registry->set('tx_scheduler', 'lastRun', $runInformation);

At some other point, the value is retrieved with the following code:

$registry = t3lib_div::makeInstance('t3lib_Registry');
$lastRun = $registry->get('tx_scheduler', 'lastRun');

More information can be found in the Core APIs.



comment #1
Gravatar: Stefano Stefano April 29, 2010 15:50
TAHNK YOU François!! i didn't really know about it! and i "thought" to have followed all 4.3 development :)

comment #2
Gravatar: myroslav myroslav April 29, 2010 16:13
Hey, it's realy good idea to store all crap in single table (sys_registry as i see), excelent work :) .

comment #3
Gravatar: Steffen Müller Steffen Müller April 29, 2010 21:25
$registry = t3lib_div::makeInstance('t3lib_Registry');
$info = array('clap' => TRUE);
$registry->set('tt_clap', 'francois', $info);

comment #4
Gravatar: Tim Tim May 5, 2010 23:35
Nice Feature. I translate it to german:

Thx François

Sorry, comments are closed for this post.