Introducing Kue - A Rails Ready Key Value Store That Uses ActiveRecord Under The Hood
A few weeks ago I wrote a post on how I had implemented a simple key value store using activerecord.
I received a lot of feedback not only via the comment's on the post but also by email. As so many people showed interest I decided to create an activerecord backed key value store gem called kue encompassing some of the idea's and thought's that people had brought to my attention.
Getting setup with kue is easy as it has a rails generator to copy over the migration needed in order to setup the underlying key value storage table.
rails generate kue:install rake db:migrate
When you want to set or retrieve any arbitrary keys value then you can do so by calling on the KueStore class.
#Set the value of the key KueStore[:any_key_name_you_can_think_of] = "Any object you can dream up" #Retrieve the value of the key KueStore[:any_key_name_you_can_think_of]
There is also a helper method to check if a key already exists.
KueStore.exists?(:my_class_instance)
One of the nice things about kue is it can store any object you can think of complex or simple!
KueStore[:my_class_instance] = Foo.new(:name => 1)
Let me know what you think. Pull requests are always welcome!