Last weekend I was working on a Rails project and realized that I was creating the same utility function for the third time in a row. In the spirit of DRY, I figured it was time to package it up into a gem that I could drop into any project.<p>The basic problem was creating a place to quickly and easily shove config values and application wide state. CONSTANTS in the environment work ok, but can't be modified by the run time. What I ultimately wanted was memcache, with persistence.<p>So I created the entity_store gem, which allows you to drop a persistent key/value store into any rails app in about 5 minutes. After initialization, you can use commands like:<p># Get key value.<p>e = EntityStore["testkey"]<p>e = EntityStore.testkey<p>e = EntityStore[:testkey]<p># sets key named 'happened' to a Time object of now<p>EntityStore[:happened] = Time.now<p>EntityStore["happened"] = Time.now<p>EntityStore.happened = Time.now<p>Everything syncs instantly with the database, so state is preserved even if the server goes down. Additionally, it allows you to initialize with some defaults for keys - which works great for getting initial state going on your app.<p>Overall, packaging up and publishing the gem in a decent state online took longer than actually writing the functionality. Talk about yak shaving! But it was fun... hope someone else finds it useful.<p>http://eatenbyagrue.github.com/entity_storage/<p>Any ideas for the next version would be greatly appreciated.