[commits] [Wiki] changed: HashTable

Jan Schneider jan at horde.org
Fri Feb 14 11:00:36 UTC 2014


jan  Fri, 14 Feb 2014 11:00:36 +0000

Modified page: http://wiki.horde.org/HashTable
New Revision:  3
Change log:  Syntax highlighting, style

@@ -1,17 +1,24 @@
-Notes on using HashTable inside a horde app - Examples as typed in  
the horde php console
+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
+++ Retrieving a !HashTable Instance
+
+<code type="php">
  $hashtable = $GLOBALS['injector']->getInstance('Horde_HashTable');
+</code>

-++ set a key and a scalar value
+++ Setting a key and a scalar value

+<code type="php">
  $hashtable->set('key1', 'value1');
+</code>

-++ set a key and a structured value by serializing
+++ Setting a key and a structured value by serializing
+
+<code type="php">
  // Mind using Horde_Pack instead
  $hashtable = $injector->getInstance('Horde_HashTable');

  $data = array('foo', 'bar');
@@ -20,13 +27,13 @@
  $hashtable->set('packed', $packed);
  $retrieved = $hashtable->get('packed');
  print $retrieved;
  print_r(unserialize($retrieved));
+</code>

+++ Checking if a key exists, retrieving

-++ check if a key exists, retrieve ==
-
+<code type="php">
  if ($hashtable->exists('key1')) {
      $result = $hashtable->get('key1');
  }
-
-
+</code>



More information about the commits mailing list