views:

182

answers:

3

Hi all,

I'm looking for an API or an application that can cache data from a file or database. My idea is that I have an application that reads a database, but the access to database is sequential and it is on a disk.

What I basically want to do is get the data from cache first and then if it doesn't exist in cache, then hit the database. Note I'm not using a mainstream database, I'm using SQLite, but my performance requirements are very high.

So is there any product or API (free or commercial) that I can use for this purpose? Also I must have an API to interface with my cache.

I want to implement something like a web server cache or something like that.

I'm using C and Unix platform.

Thanks

+8  A: 

You might want to look at using a shared memory cache such as memcached, although this requires a separate daemon, or roll something similar for yourself.

One thing I'd mention is that you should probably do some actual benchmarking to check that your database is your bottleneck, and if performance is a real concern there, then you're going to have to consider scaling up to a non-embedded DBMS. If that's not an option, then you may still be able to optimise the existing database accesses (query optimisation, indices, etc.).

Rob
Exactly. Profile it before optimize it. +1 for that.
PolyThinker
+5  A: 

Check out memcached. Brian Aker has written a C library for it.

But I would also second Rob's suggestion. SQLite and "performance requirements are very high" may not necessarily go together, depending on what aspect of performance you mean.

Abie
+1  A: 

You might try Zola's CaLi library: http://icis.pcz.pl/~zola/CaLi/

Chad Brewbaker