Browse Source

rename fast-cache to ferrite

master
Brett Langdon 13 years ago
parent
commit
916d64d31d
8 changed files with 52 additions and 24 deletions
  1. +17
    -6
      Makefile
  2. +23
    -6
      README.md
  3. +2
    -2
      src/common.h
  4. +2
    -2
      src/handlers.h
  5. +2
    -2
      src/main.c
  6. +2
    -2
      src/proxy.h
  7. +2
    -2
      src/queue.h
  8. +2
    -2
      src/util.h

+ 17
- 6
Makefile View File

@ -1,21 +1,32 @@
INSTALL=/usr/bin/install
CFLAGS=$(shell curl-config --cflags) -Wall $(EXTRA_CFLAGS) CFLAGS=$(shell curl-config --cflags) -Wall $(EXTRA_CFLAGS)
LFLAGS=$(shell curl-config --libs) -lpthread -lkyotocabinet LFLAGS=$(shell curl-config --libs) -lpthread -lkyotocabinet
CC=gcc CC=gcc
PREFIX=/usr/local
BINDIR = $(PREFIX)/bin
default: fast-cache
default: ferrite
src/%.o: src/%.c src/%.h src/%.o: src/%.c src/%.h
$(CC) -c $(CFLAGS) -o $@ $< $(CC) -c $(CFLAGS) -o $@ $<
fast-cache: ./src/util.o ./src/queue.o ./src/proxy.o ./src/handlers.o ./src/main.o
ferrite: ./src/util.o ./src/queue.o ./src/proxy.o ./src/handlers.o ./src/main.o
$(CC) $(CFLAGS) -o $@ $^ $(LFLAGS) $(CC) $(CFLAGS) -o $@ $^ $(LFLAGS)
debug: debug:
make -f Makefile EXTRA_CFLAGS="-g"
make -f Makefile EXTRA_CFLAGS="-g -O0"
run: run:
./fast-cache
./ferrite
.PHONY: clean debug release
release: clean
make -f Makefile EXTRA_CFLAGS="-O3"
install:
$(INSTALL) ./ferrite $(BINDIR)
clean: clean:
rm ./src/*.o
rm ./fast-cache
rm -f ./src/*.o
rm -f ./ferrite

+ 23
- 6
README.md View File

@ -1,4 +1,4 @@
fast-cache
ferrite
========== ==========
A very fast kyoto cabinet powered memcached interface API proxy caching server. A very fast kyoto cabinet powered memcached interface API proxy caching server.
@ -8,24 +8,40 @@ you interact with it via a subset of the memcached commands. The main purpose is
`http://api.my-domain.com/api/` and then you make memcache get calls like `get/users` or `user/12` or any other `http://api.my-domain.com/api/` and then you make memcache get calls like `get/users` or `user/12` or any other
GET only api end point. The result content does not matter at all (which means you could use this to cache HTTP get calls). GET only api end point. The result content does not matter at all (which means you could use this to cache HTTP get calls).
The other _very_ important thing about `fast-cache` is that when it gets a cache miss it does now wait around for a response
The other _very_ important thing about `ferrite` is that when it gets a cache miss it does now wait around for a response
from the proxy server, it will send back an empty string to the client making the request and then queue up the request to from the proxy server, it will send back an empty string to the client making the request and then queue up the request to
the proxy server. This means that although you will get back an empty string when you get a cache miss your response times the proxy server. This means that although you will get back an empty string when you get a cache miss your response times
from this proxy server will be consistent (which can be very important for high performance applications). from this proxy server will be consistent (which can be very important for high performance applications).
## Name
The name `ferrite` comes from: [Ferrite Magnet](http://en.wikipedia.org/wiki/Ferrite_(magnet))
## Install ## Install
### Requirements ### Requirements
* Kyoto Cabinet Installed * Kyoto Cabinet Installed
* libcurl Installed * libcurl Installed
```bash ```bash
git clone git://github.com/brettlangdon/fast-cache.git
cd ./fast-cache
make
# now you have a binary "./fast-cache" available, there is not `make install` yet
git clone git://github.com/brettlangdon/ferrite.git
cd ./ferrite
make release
make install
``` ```
## Using ## Using
## Usage
```bash
$ ferrite --help
Usage: ferrite [-h|--help] [-p|--port <NUM>] [-w|--workers <NUM>] [-u|--url <STRING>] [-c|--cache <STRING>] [-e|--expire <NUM>]
-p, --port - which port number to bind too [default: 7000]
-w, --workers - how many background workers to spawn [default: 10]
-u, --url - which url to proxy requests to [default: http://127.0.0.1:8000]
-c, --cache - kyoto cabinet cache to use [default: "*"]
-e, --exp - the expiration time in seconds from when a record is cached, 0 to disable [default:3600]
-h, --help - display this message
```
## Memcache Client
Just use your favorite memcache client Just use your favorite memcache client
```python ```python
import pymemcache.client import pymemcache.client
@ -33,6 +49,7 @@ mc = pymemcache.client.Client([("127.0.0.1", 7000)])
users = mc.get("/all/users") users = mc.get("/all/users")
``` ```
## Telnet
```bash ```bash
telnet 127.0.0.1 7000 telnet 127.0.0.1 7000
Trying 127.0.0.1... Trying 127.0.0.1...


+ 2
- 2
src/common.h View File

@ -1,5 +1,5 @@
#ifndef FAST_CACHE_COMMON
#define FAST_CACHE_COMMON
#ifndef FERRITE_COMMON
#define FERRITE_COMMON
#include "queue.h" #include "queue.h"
extern sig_atomic_t misses; extern sig_atomic_t misses;


+ 2
- 2
src/handlers.h View File

@ -1,5 +1,5 @@
#ifndef FAST_CACHE_HANDLERS
#define FAST_CACHE_HANDLERS
#ifndef FERRITE_HANDLERS
#define FERRITE_HANDLERS
#include <kclangc.h> #include <kclangc.h>
#include <time.h> #include <time.h>
#include "common.h" #include "common.h"


+ 2
- 2
src/main.c View File

@ -30,7 +30,7 @@ static struct option long_options[] = {
void usage(){ void usage(){
const char* usage_str = const char* usage_str =
"Usage: fast-cache [-h|--help] [-p|--port <NUM>] [-w|--workers <NUM>] [-u|--url <STRING>]\r\n"
"Usage: ferrite [-h|--help] [-p|--port <NUM>] [-w|--workers <NUM>] [-u|--url <STRING>]\r\n"
" [-c|--cache <STRING>] [-e|--expire <NUM>]\r\n" " [-c|--cache <STRING>] [-e|--expire <NUM>]\r\n"
"\t-p, --port\t- which port number to bind too [default: 7000]\r\n" "\t-p, --port\t- which port number to bind too [default: 7000]\r\n"
"\t-w, --workers\t- how many background workers to spawn [default: 10]\r\n" "\t-w, --workers\t- how many background workers to spawn [default: 10]\r\n"
@ -68,7 +68,7 @@ void* worker(void* arg){
} }
void on_signal(){ void on_signal(){
printf("Shutting down fast-cache\r\n");
printf("Shutting down ferrite\r\n");
if(server){ if(server){
printf("Closing socket\r\n"); printf("Closing socket\r\n");
shutdown(server, 2); shutdown(server, 2);


+ 2
- 2
src/proxy.h View File

@ -1,5 +1,5 @@
#ifndef FAST_CACHE_PROXY
#define FAST_CACHE_PROXY
#ifndef FERRITE_PROXY
#define FERRITE_PROXY
#include <curl/curl.h> #include <curl/curl.h>
#include <time.h> #include <time.h>


+ 2
- 2
src/queue.h View File

@ -1,5 +1,5 @@
#ifndef FAST_CACHE_QUEUE
#define FAST_CACHE_QUEUE
#ifndef FERRITE_QUEUE
#define FERRITE_QUEUE
#include <kclangc.h> #include <kclangc.h>
#include <pthread.h> #include <pthread.h>


+ 2
- 2
src/util.h View File

@ -1,5 +1,5 @@
#ifndef FAST_CACHE_UTIL
#define FAST_CACHE_UTIL
#ifndef FERRITE_UTIL
#define FERRITE_UTIL
#include <kclangc.h> #include <kclangc.h>


Loading…
Cancel
Save