Redis是一個高性能的key-value數據庫。redis的出現,很大程度補償了memcache這類key-value存儲的不足,在部分場合能夠對關係數據庫起到很好的補充做用。它提供了Python,Ruby,Erlang,PHP客戶端,使用很方便。
性能測試結果:SET操做每秒鐘110000 次,GET操做每秒鐘81000 次
有了Redis做爲保障,新架構就能夠開搞了,使用到的主要關鍵詞由openResty,LuaJit,Lua,Redis,PHP,PHPRedis,JSon,JQuery等組成。讀者能夠搜索下各名詞瞭解它們的功能。下面是openResty中的Nginx配置:
nginx.conf
server {
listen 80;
root/home/boolean/Htdocs/lib.bincent.com;
index index.htmlindex.htm;
server_namelib.bincent.cn;
#默認請求Html轉發到apache,這裏你能夠根據本身狀況配置
location /
{
proxy_redirect off;
proxy_set_header HOST$host;
proxy_set_headerSERVER_ADDR $server_addr;
proxy_set_headerSERVER_PORT $server_port;
proxy_set_headerREMOTE_ADDR $remote_addr;
proxy_set_headerREMOTE_PORT $remote_port;
proxy_pass http://lib.bincent.cn:8080;
}
#更新redis
location /set_redis
{
internal;
set_unescape_uri$key $arg_key;
set_unescape_uri$val $arg_val;
redis2_queryset $key $val;
redis2_pass127.0.0.1:6379;
}
#讀取redis
location /get_redis
{
internal;
set_unescape_uri$key $arg_key;
redis2_queryget $key;
redis2_pass127.0.0.1:6379;
}
# 模擬的簡單請求
location /json
{
default_typetext/html;
content_by_lua_file/home/boolean/Htdocs/lib.bincent.com/lua/redis.lua;
}
}
redis.lua文件
#經過URL更新redisphp