NuSTER 是一个基于 HAProxy 的高性能 HTTP 缓存服务器和 RESTful NoSQL 缓存服务器,既可以用作类似 Varnish 或者 Nginx 那样的 HTTP 缓存服务器,来缓存动态或者静态的 HTTP 资源,也可以用作 RESTful NoSQL 缓存服务器, 用 HTTP POST/GET/DELETE 来 添加 /取得 /删除 Key/Value。
https://github.com/jiangwenyuan/nuster
可以像 Memcached 或者 Redis 那样放在应用和数据库之间作为内部 KV 缓存使用,也可以放在用户和应用之间作为面向用户的 NoSQL 使用。 支持 header, cookie 等等,所以可以将不同的用户数据存到相同的路劲。
curl -v -X POST -d value1 http://127.0.0.1:8080/key1 curl -v -X POST --data-binary @icon.jpg http://127.0.0.1:8080/imgs/icon.jpg
curl -v http://127.0.0.1:8080/key1
curl -v -X DELETE http://127.0.0.1:8080/key1
Check status code.
200 OK POST/GET: 成功 DELETE: 总是 400 Bad request 空值 不正确的 acl, rules, etc 404 Not Found POST: rule tests 失败 GET: not found 405 Method Not Allowed 其他的 methods 500 Internal Server Error 发生未知错误 507 Insufficient Storage 超过 data-size
通过在 key 里加入 header, cookie 等等,可以将不同的用户数据存到相同的路劲。
nuster rule r1 key method.scheme.host.uri.header_userId if { path /mypoint } nuster rule r2 key method.scheme.host.uri.cookie_sessionId if { path /mydata }
curl -v -X POST -d "333" -H "userId: 1000" http://127.0.0.1:8080/mypoint curl -v -X POST -d "555" -H "userId: 1001" http://127.0.0.1:8080/mypoint curl -v -X POST -d "userA data" --cookie "sessionId: ijsf023xe" http://127.0.0.1:8080/mydata curl -v -X POST -d "userB data" --cookie "sessionId: rosre329x" http://127.0.0.1:8080/mydata
curl -v http://127.0.0.1:8080/mypoint < 404 Not Found curl -v -H "userId: 1000" http://127.0.0.1:8080/mypoint < 200 OK 333 curl -v --cookie "sessionId: ijsf023xe" http://127.0.0.1:8080/mydata < 200 OK userA data
支持任何语言,不需要第三方库,只要支持 HTTP 的客户端 /库: curl, postman, python requests
, go net/http
, etc.