Skip to content

Commit

Permalink
Add backend examples
Browse files Browse the repository at this point in the history
Signed-off-by: Vicent Marti <tanoku@gmail.com>
  • Loading branch information
vmg committed Dec 9, 2010
1 parent 187d06b commit a4602c0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions api.html
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,17 @@ <h3 id="indexread">Implementing a custom backend</h3>
it to an existing object database using the <code>git_odb_add_backend(backend)</code> method.
A single backend instance can only be active in one ODB at the same time</p>

<p>The <code>priority</code> field is used to when sorting the backends for their usage:
for instance, a <code>read</code> call on the ODB will first check the backend with the
highest priority and attempt to read the object from it; if the backend returns an error
code, it will fallback silently to the following backend, until the object has been read
or there are no more backends left.</p>

<p>It it not necessary to specify all the backend methods on a custom backend: unspecified
methods will be skipped silently on their respective backend calls. If no <code>free</code>
method is specified for a given backend, the library will automatically try to free the backend using
a plain <code>free()</code> call.</p>

<span class="shtitle">Ruby</span>
<pre class="sh_ruby">
class TestBackend &lt; Rugged::Backend
Expand Down Expand Up @@ -702,6 +713,20 @@ <h3 id="indexread">Implementing a custom backend</h3>
@repo.add_backend(backend)
</pre>

<h3 id="indexread">A world of possibilities</h3>

<p>The options when implementing custom backends are endless. Here are just a few examples:</p>

<ul>
<li>in-memory object storage (useful for config storage)</li>
<li>in-memory cache for fast lookups (make sure you write the objects back to disk before flushing the cache!)</li>
<li>a transparent backend acting as a logger for all the ODB reads and writes</li>
<li>SQLite backend writing and reading objects from a compact database</li>
<li>Cassandra backend (or your favourite NoSQL flavour!)</li>
<li>Network backend (store the objects remotely, directly)</li>
<li>...Oh my god, so many cool ideas!</li>
</ul>

</div>
</div></div>

Expand Down

0 comments on commit a4602c0

Please sign in to comment.