Friday, July 04, 2014

SQLitePCL vs Akavache

Earlier this week I shared the news that there is now an "official(ish)" version of SQLite that can be used in what Microsoft calls "Universal Apps".

I was asked how this compares with using Akavache and if I have any recommendations?

If you're not familiar Akavache it's "an asynchronous, persistent key-value store for native applications". In that it can use SQLite as its data store and that both can be used in Windows and Windows Phone apps then the comparison question becomes even more relevant.

That's to risk potential confusion though. The underlying data source isn't really relevant. What matters is what their purpose is and what they're capable of.

The first big difference between the two options is in the type of data they can store. SQLite allows the storing of relational data. (It is a relational database after all.) Akavache can just store key-value pairs.

Of course you could just store key-value data in SQLite yourself. So why use Akavache?
The answer lies in what it adds beyond just being a key-value store. It is designed for working with (and storing) remote data that may be cached. Whether that's HTTP response, images or JSON data. Akavache adds more than just a key value store it provides smart logic for retrieving and caching remote resources.

So, my recommendation is that if you only need to store remotely sourced key-value pairs then use Akavache. If you need to store relational data then use SQLite.

4 comments:

  1. Great article. One thing that definitely leads you to using raw SQLite3 over Akavache is if you need *queries* over data - i.e. if you need to say, "Give me all the Twitter messages from April 4th", Akavache won't be great at that. It is great at doing many tasks that typical client apps do, like serializing objects for you, or refreshing a list while returning you the cached items.

    You can always use Akavache and SQLite3 together though, and in fact, in Akavache 4.0 we'll expose the database connection directly so that you can glom onto the existing database for your own tables.

    ReplyDelete
    Replies
    1. (This is Paul, the author of Akavache, but this comment frame is getting Confused™)

      Delete
  2. Thank you Matt and Paul, such nuggets are invaluable.

    ReplyDelete

I get a lot of comment spam :( - moderation may take a while.