Created
February 27, 2010 21:17
-
-
Save trydionel/316957 to your computer and use it in GitHub Desktop.
Lightning-Quick Redis Viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'haml' | |
require 'sinatra' | |
require 'redis' | |
helpers do | |
def redis | |
@redis ||= Redis.new | |
end | |
end | |
get "/" do | |
@keys = redis.keys("*") | |
haml :index | |
end | |
get "/:key" do | |
@key = params[:key] | |
@data = case redis.type(@key) | |
when "string" | |
Array(redis[@key]) | |
when "list" | |
redis.lrange(@key, 0, -1) | |
when "set" | |
redis.set_members(@key) | |
else | |
[] | |
end | |
haml :show | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%html | |
%body | |
%h1 Current Keys | |
%ul | |
-@keys.each do |key| | |
%li | |
%a{:href => "/#{key}"}= key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%html | |
%body | |
%h1= "Data stored in '#{@key}'" | |
%ul | |
-@data.each do |data| | |
%li | |
%p= data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment