I must remove sql dependency of small portions of information which i strain on (almost) each request on the web application. The majority of the information is key-value/document structured, but a relational option would be not excluded. The information isn't too large so I wish to ensure that it stays in memory for greater availability.
What solution can you recommend?
The easiest and many broadly utilized in-memory Key-value storage is MemcacheD. The introduction page re-iterates what you're requesting:
Memcached is definitely an in-memory key-value store for small portions of arbitrary data (strings, objects) from outcomes of database calls, API calls, or page rendering.
The customer list is impressive. It has been for any very long time. Good documentation. It's API for nearly every programming language. Horizontal scaling is fairly simple. As my experience goes Memcached is nice.
You may even wish to consider MemBase.
Redis is ideal for this type of data. Additionally, it supports some rudimentary datastructures and offers procedures in it.
I lately converted my Django forum application for doing things for those real-time/monitoring data - it is so good to no more possess the icky feeling you receive if you do this type of stuff (
SET views = views + 1 along with other creates on every page view) having a relational database.
Here's a good example of using Redis to keep data needed for user activity monitoring, including keeping an purchased group of last seen customers current, in Python:
def seen_user(user, doing, item=None): """ Stores what a User was doing when they were last seen and updates their last seen time in the active users sorted set. """ last_seen = int(time.mktime(datetime.datetime.now().timetuple())) redis.zadd(ACTIVE_USERS, user.pk, last_seen) redis.setnx(USER_USERNAME % user.pk, user.username) redis.set(USER_LAST_SEEN % user.pk, last_seen) if item: doing = '%s <a href="%s">%s</a>' % ( doing, item.get_absolute_url(), escape(str(item))) redis.set(USER_DOING % user.pk, doing)
If you do not mind the sql but wish to keep your db in memory, you might like to take a look at sqlite (see http://www.sqlite.org/inmemorydb.html).
If you do not want the sql and also you really have only key-value pairs, why don't you just store these questions map / hash / associative array and that would be that?
I am unsure this is exactly what you're searching for however, you should consider a caching framework (something which might be incorporated within the tools you're using now). Having a repository pattern you request for that data, there you check for those who have it in cache by key. I you do not, you fetch it in the database, should you choose, you fetch it in the cache.
It'll rely on what type of data you're handling so the choice is yours to determine how lengthy to help keep data in cache. Possibly a sliding timeout is better as you'll keep your data as lengthy because the key keeps being request. Meaning when the cache has data for any user, when the user disappears, the information will expire in the cache.
Should you finish up requiring an in-memory database, H2 is an extremely wise decision.
Yet another database to think about: Berkeley DB. Berkeley DB enables you to definitely configure the database to stay in-memory, on-disk or both. It supports both a vital-value (NoSQL) along with a SQL API. Berkeley DB is frequently used in conjunction with web programs since it is embedded, easily used (it deploys together with your application), highly configurable and incredibly reliable. You will find several e-Retail internet sites that depend on Berkeley DB for his or her e-Commerce programs, including Amazon . com.com.