Permalink
Browse files

App that creates caches dynamically, to test Brian's issue.

  • Loading branch information...
jcrossley3 committed May 6, 2011
1 parent 7dc1108 commit fe0e57aaef2a64f79d1877966f1be43aa61e7534
Showing with 32 additions and 0 deletions.
  1. +5 −0 cache-creator/Gemfile
  2. +1 −0 cache-creator/Rakefile
  3. +24 −0 cache-creator/cache-creator.rb
  4. +2 −0 cache-creator/config.ru
View
@@ -0,0 +1,5 @@
+source "http://rubygems.org"
+gem "sinatra"
+gem "i18n"
+gem "torquebox"
+gem "activesupport"
View
@@ -0,0 +1 @@
+require "torquebox-rake-support"
@@ -0,0 +1,24 @@
+require 'sinatra/base'
+require 'active_support/cache/torque_box_store'
+include ActiveSupport::Cache
+
+class CacheCreator < Sinatra::Base
+
+ set :caches, {}
+
+ get '/create/:name' do
+ name = params[:name]
+ cache = (settings.caches[name] = TorqueBoxStore.new(:name => name, :mode => :dist))
+ "create #{cache}\n"
+ end
+
+ get '/read/:name/:key' do
+ value = settings.caches[params[:name]].read(params[:key])
+ "read #{params[:name]}[#{params[:key]}]==#{value}\n"
+ end
+
+ get '/write/:name/:key/:value' do
+ settings.caches[params[:name]].write(params[:key], params[:value])
+ "write #{params[:name]}[#{params[:key]}]=>#{params[:value]}\n"
+ end
+end
View
@@ -0,0 +1,2 @@
+require 'cache-creator'
+run CacheCreator

0 comments on commit fe0e57a

Please sign in to comment.