The easiest thing to do would be to cache at a higher level than the database-connectivity level. If you have a data access layer that encapsulates you from the nitty-gritties of SQL, that's usually a good place. If you have a place where data objects are requested, that would be even better; your caching key can be the identity of those objects.
What you ultimately will probably want is a caching Proxy which encapsulates your caching logic, interdicting reads but passing writes through to the underlying service (the object persistence layer or the data access layer). You can use WeakReference
to cause unused objects to expire out of your caching collection, in which case you'll need to do just a little bit of clean up. On the other hand you can write your own expiration logic, in which case you have to do more clean up but will retain more control.
Without more specific details, it's hard to give you a specific answer.