[commits] [Wiki] changed: HashTable
Ralf Lang (B1 Systems GmbH)
lang at b1-systems.de
Tue Feb 4 11:20:20 UTC 2014
rlang Tue, 04 Feb 2014 11:20:20 +0000
Modified page: http://wiki.horde.org/HashTable
New Revision: 2
Change log: wikify
@@ -1,9 +1,32 @@
-Notes on using HashTable inside a horde app
+Notes on using HashTable inside a horde app - Examples as typed in
the horde php console
You need to configure a hash table first - there is a HashTable tab
in the Horde config.
If you use Redis, you need the nrk channel Predis package first.
-// Retrieve a HashTable Instance
+++ Retrieve a HashTable Instance
$hashtable = $GLOBALS['injector']->getInstance('Horde_HashTable');
+
+++ set a key and a scalar value
+
+$hashtable->set('key1', 'value1');
+
+++ set a key and a structured value by serializing
+// Mind using Horde_Pack instead
+$hashtable = $injector->getInstance('Horde_HashTable');
+
+$data = array('foo', 'bar');
+$packed = serialize($data);
+
+$hashtable->set('packed', $packed);
+$retrieved = $hashtable->get('packed');
+print $retrieved;
+print_r(unserialize($retrieved));
+
+
+++ check if a key exists, retrieve ==
+
+if ($hashtable->exists('key1')) {
+ $result = $hashtable->get('key1');
+}
More information about the commits
mailing list