發表文章

Markdown

[Redis] How to use redis in symfony

Redis https://www.linode.com/docs/databases/redis/install-and-configure-redis-on-centos-7 introduce http://blog.techbridge.cc/2016/06/18/redis-introduction/ SETTING https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md https://www.slideshare.net/ricardclau/speed-up-your-symfony2-application-and-build-awesome-features-with-redis

[Redis] KEY 設計

http://yhhuang1966.blogspot.tw/2015/07/lua_14.html http://blog.csdn.net/irean_lau/article/details/51395515 結構圖: https://www.zhihu.com/question/36413559 https://github.com/liukelin/canal_mysql_nosql_sync http://blog.nosqlfan.com/html/3033.html https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md https://www.oschina.net/translate/mysql-to-redis-in-one-step https://gnuhpc.gitbooks.io/redis-all-about/CodeDesignRule/keydesign.html ... 3 75 $redis = $this->container->get('snc_redis.default');~ 3 76 $redis->SET("bank:bankid:$registerID:username","$registerUsername");~ 3 77 $redis->SET("bank:bankid:$registerID:paassword","$registerPassword");~ 3 78 $redis->SET("bank:bankid:$registerID:balance",'0');~ ... 127.0.0.1:6379> KEYS * 1) "bank:bankid:121:balance" 2) "bank:bankid:121:username" 3) "bank:bankid:121:paass...

[Symfony] How to get the get request query parameter

Access-Control-Allow-Origin:* Cache-Control:no-cache, private Connection:keep-alive Content-Type:application/json Date:Fri, 23 Jun 2017 07:44:50 GMT Server:nginx/1.10.2 Transfer-Encoding:chunked X-Powered-By:PHP/5.6.30 Request Headers view parsed GET /bank/search?{%22id%22:%221%22,%22behavior%22:%22deposit%22,%22from%22:%220%22,%22to%22:%22100%22} HTTP/1.1 Host: test123 Connection: keep-alive Accept: text/plain,  / ; q=0.01 Origin: null User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4 Query String Parameters view source view URL encoded {“id”:“1”,“behavior”:“deposit”,“from”:“0”,“to”:“100”}: 觀察一下標頭 可以發現參數是帶在URL後面那串 跟POST 不一樣 東西可以夾在content裡面 所以原本使用$request->getContent() 的方式就不管用了 應該根據不同的METHOD 換成以下方法 AJAX的部分也應該把DATA參數直接帶入,不能做josn化,因為會變成字串 use Symfony \ Component \ HttpFoundation \ Request ; public functi...

[Linux] How To CURL with JSON

register curl -H "Content-Type: application/json" -X POST -d '{"username":"xyz","password":"xyz"}' http://127.0.0.1:8000/bank/register SERACH curl -H "Content-Type: application/json" -X POST -d '{"id":"1","behavior":"deposit","from":"0","to":"100"}' http://127.0.0.1:8000/bank/serach deposit curl -H "Content-Type: application/json" -X POST -d '{"id":"1","amount":"100"}' http://127.0.0.1:8000/bank/deposit withdrawals curl -H "Content-Type: application/json" -X POST -d '{"id":"1","amount":"100"}' http://127.0.0.1:8000/bank/withdrawals

[Symfony] How to request with json in ApacheBench

https://gist.github.com/kelvinn/6a1c51b8976acf25bd78 # post_loc.txt contains the json you want to post # -p means to POST it # -H adds an Auth header (could be Basic or Token) # -T sets the Content-Type # -c is concurrent clients # -n is the number of requests to run in the test ab -p -T application/json -H 'id:1,amount:1' -c 10 -n 2000 http://127.0.0.1:8000/bank/deposit deposit ab -p ./abdpost.txt -T application/json -c 10 -n 2000 http://127.0.0.1:8000/bank/deposit withdrawals ab -p ./abdpost.txt -T application/json -c 10 -n 2000 http://127.0.0.1:8000/bank/withdrawals