Archive for 7月, 2012

 

kyototycoon luaで2つのデータベースを利用。

7月 13th, 2012

$ lua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio [http://fallabs.com/blog-ja/promenade.cgi?id=124] 2つのハッシュデータベースにデータを入れるだけ 1つ目は、idとデータ 2つ目は、keyとidリスト アイテムテーブルとユーザーテーブルのような関係。 起動コマンドは、サンプルの通り scrにスクリプトを設定する Starting the server of Kyoto Tycoon Executing: ktserver -port 50311 -dmn -pid /var/ktserver/first/pid -tout 3 -log /var/ktserver/first/log -scr /home/first/backend/lua/first.lua Done first.kch user.kchとして起動 1. script : idとuserでdataを登録する。 $ ktremotemgr script -port 50311 set id 100 user fujisan data “{id:100,user:fujisan,etc}” 2. […]

Read full article | コメントは受け付けていません。

kyotocabinet kyototycoonをインストールしてluaでスクリプト追加してみる。

7月 12th, 2012

centos 6です。 zlibが必要。 luaを入れる。 yum install lua lua-devel 最新のパッケージをダウンロードします。 http://fallabs.com/kyotocabinet/ http://fallabs.com/kyototycoon/ //fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz //http://fallabs.com/kyototycoon/pkg/kyototycoon-0.9.56.tar.gz ./configure make make install で。 kyototycoonには、./configure –enable-lua とオプションを付ける。 checking for lua.h… yesが入る。 make; make install ktserver: error while loading shared libraries: libkyototycoon.so.2: cannot open shared object file: No such file or directory # vim /etc/ld.so.conf.d/ktserver.conf /usr/local/libを追加。 /sbin/ldconfig -v /usr/local/lib: libkyototycoon.so.2 -> libkyototycoon.so.2.19.0 libkyotocabinet.so.16 […]

Read full article | コメントは受け付けていません。

goo.gl shortener api

7月 10th, 2012

https://developers.google.com/url-shortener/v1/getting_started OAuth 2.0で使えるようです。 or apikey or 何も無し。 とりあえず。何も無しで使ってみます。 $api = ‘https://www.googleapis.com/urlshortener/v1/url'; $post_data = json_encode(array(‘longUrl’ => $url )); curl_setopt($ch, CURLOPT_URL, $api ); curl_setopt($ch,CURLOPT_HTTPHEADER,array (“Content-Type: application/json” )); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2); $json = curl_exec($ch); curl_close($ch); jsonデータをpostするだけです。 { “kind”: “urlshortener#url”, “id”: “http://goo.gl/xSJmh”, “longUrl”: “http://blog.bbtune.com/” } 無事、こんなデータが。 で戻すときは Expand […]

Read full article | コメントは受け付けていません。

json_decode, unserializeの比較 | php

7月 3rd, 2012

ascii文字列10文字 json:0.00083112716674805 php :0.0003509521484375 2.3682065217391 日本語文字列10文字 $j=’”\u3042\u3044\u3046\u3048\u304a\u304b\u304d\u304f\u3051\u3053″‘; $p=’s:30:”あいうえおかきくけこ”;'; json:0.0024328231811523 php :0.00071287155151367 3.4127090301003 適当な配列+数字 $j='{“a”:1000,”b”:{“c”:999}}'; $p=’a:2:{s:1:”a”;i:1000;s:1:”b”;a:1:{s:1:”c”;i:999;}}'; json:0.0030450820922852 php :0.0014889240264893 2.0451561248999 decode変換はphpの方が速い。 ちなみに、json_encode, serializeは同じくらいでした。 こんな感じ。 json:0.026504039764404 php :0.02891993522644

Read full article | コメントは受け付けていません。

ユーザー毎の制限 ulimit | failed to open stream: Too many open files’

7月 3rd, 2012

1ユーザーで並列にたくさん動かしたので、ファイルを開ける数に制限が出てしまいました。 failed to open stream: Too many open files’ in Zend/Search/Lucene/Storage/File/Filesystem.php:67 ulimit -n 1024 です。並列に動かす総定数 * 1024に変更します。 /etc/security/limits.conf username soft nofile 4096 username hard nofile 4096 ログインすると $ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 15903 […]

Read full article | コメントは受け付けていません。