0.0
No commit activity in last 3 years
No release in over 3 years
Drop-in page caching using nginx, lua, and memcached.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0

Runtime

~> 1.5.0
 Project Readme

#Nginx Accelerator

Drop-in page caching using nginx, lua, and memcached.

##Features

  • Listens to Cache-Control max-age header
  • The memcached key is the URI (easy to expire on demand)
  • Really, really fast

##Requirements

You'll need an nginx build with the following modules:

##Configure nginx

###nginx.conf

Drop the following line in any location directive:

access_by_lua "require('accelerator').access()";

For example:

http {
  server {
    listen 8080;

    location = / {
      access_by_lua "require('accelerator').access()";
    }
  }
}

The TTL is based on Cache-Control: max-age, but defaults to 10 seconds.

To configure your memcached connection information:

access_by_lua "require('accelerator').access({ host='127.0.0.1', port=11211 })";

Ruby client

Install gem

gem install accelerator

Example

cache = Accelerator.new("localhost:11211")
cache.get("/test")
cache.set("/test", "body")
cache.delete("/test") 
cache.expire("/test", 10)

Running specs

###Install Lua and Moonscript

brew install lua
brew install luarocks
luarocks build http://moonscript.org/rocks/moonscript-0.2.3-2.rockspec

Add moonscript to your path:

export PATH=$PATH:/usr/local/lib/luarocks/bin/

###Install nginx-accelerator rock via luarocks

git clone git://github.com/winton/nginx-accelerator.git
cd nginx-accelerator
luarocks make

###Install PCRE

brew update
brew install pcre

###Install OpenResty (nginx)

curl -O http://openresty.org/download/ngx_openresty-1.2.6.6.tar.gz
tar xzvf ngx_openresty-1.2.6.6.tar.gz
cd ngx_openresty-1.2.6.6/

Get your PCRE version:

brew info pcre

Replace VERSION below with the PCRE version:

./configure --with-luajit --with-cc-opt="-I/usr/local/Cellar/pcre/VERSION/include" --with-ld-opt="-L/usr/local/Cellar/pcre/VERSION/lib" --prefix=~/OpenResty
make
make install

###Start nginx

cd nginx-accelerator
./nginx/start

Run specs

bundle install
bundle exec rspec spec