\documentclass{article}
\usepackage{ulem}
\usepackage{graphicx}
\usepackage{hyperref}
\pagestyle{headings}
\begin{document}
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 <a href="https://wiki.horde.org/HashTable">HashTable</a> tab in the Horde config.<br />
If you use Redis, you need the nrk channel Predis package first.

\section{Retrieving a HashTable Instance}
<pre><code class="language-php">
\$hashtable = \$GLOBALS['injector']->getInstance('Horde\_HashTable');
</code></pre>
\section{Setting a key and a scalar value}
<pre><code class="language-php">
\$hashtable->set('key1', 'value1');
</code></pre>
\section{Setting a key and a structured value by serializing}
<pre><code class="language-php">
// 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));
</code></pre>
\section{Checking if a key exists, retrieving}
<pre><code class="language-php">
if (\$hashtable->exists('key1')) \{
    \$result = \$hashtable->get('key1');
\}
</code></pre>
\end{document}
