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!

Tweet Me | Link To Facebook
Saturday, 24th December, 2011
gravatar
sounds familiar https://github.com/grosser/key_value :)
Saturday, 24th December, 2011
gravatar
Very simular! I promise I did not copy you :-). I am going to steal the remove key method for
the kue api!
Tuesday, 27th December, 2011
gravatar
It looks like you've done something similar to my project as well, https://github.com/timo3377/simple_eav. If you're cool with it I may point people over to kue? It has a cooler name.
Tuesday, 27th December, 2011
gravatar
Yeah the name is good (big lol)! I am happy if you want to point people over. Cheers.