Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

fragment cache on Sinatra

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 README.textile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 sinatra-memcache.gemspec
README.textile

Sinatra-MemCache

Dependencies

memcache-client

zlib

Install

sudo gem install gioext-sinatra-memcache

Example

require 'rubygems'
require 'sinatra'
require 'sinatra/memcache'

# cache
get '/cache1' do
  cache 'cache1' do
    sleep(5)
    'Hello Cache1'
  end
end

# args
get '/cache2' do
  cache 'cache2', :expiry => 10, :compress => true do
    sleep(3)
    'Hello Cache2'
  end
end

# cache object
get '/obj' do
  hash = cache 'obj' do
    sleep(2)
    { :a => 'Hello Object' }
  end
  hash[:a]
end

# expire
get '/expire' do
  expire 'cache1'
  expire /^cache/
  expire //
  'Hello Expire'
end

# default options
set :cache_server, "localhost:11211"
set :cache_namespace, "sinatra-memcache"
set :cache_enable, true
set :cache_logging, true
set :cache_default_expiry, 3600
set :cache_default_compress, false

License

Copyright © 2009 Kazuki UCHIDA

Licensed under the MIT License:

- http://www.opensource.org/licenses/mit-license.php

Something went wrong with that request. Please try again.