Download presentation
Presentation is loading. Please wait.
Published byGloria Hampton Modified over 9 years ago
1
memcached HTTPd mcd DB HTTPd mcd [memcached 설치 및 구동 ] -- memory object caching system *) 설정 없음 1. 설치 - memcached http://www.danga.com/memcached/ or /usr/ports/databases/memcached - libevent 패키지 필요 /usr/ports/devel/libevent or http://www.monkey.org/~provos/libevent/ 2. 구동 /usr/local/bin/memcached -d -m 256 -c 1024 -u nobody memcached 1.1.10 -p port number to listen on -l interface to listen on, default is INDRR_ANY -d run as a daemon -u assume identity of (only when run as root) -m max memory to use for items in megabytes, default is 64 MB -c max simultaneous connections, default is 1024 -k lock down all paged memory -v verbose (print errors/warnings while in event loop) -vv very verbose (also print client commands/reponses) -h print this help and exit -i print memcached and libevent license 3. client API download : http://www.danga.com/memcached/apis.bmlhttp://www.danga.com/memcached/apis.bml PHP extension : http://pecl.php.net/package/memcache/ recommendhttp://pecl.php.net/package/memcache/ 1 2 3 1-2 1) local 의 memcached 에 connect & get 2) 값이 없다면 DB 에 connect 3) 2) 의 값이 있다면 memcached 에 addition or replace * caching 대상 (resource 은 caching 이 안됨 ) - integer - string - array - object *mcd : memcached
2
Usage of memcached PHP API [download] - http://pecl.php.net/package/memcache/http://pecl.php.net/package/memcache/ or - http://cvs.php.net/pecl/memcache/http://cvs.php.net/pecl/memcache/ [install] shell> pear install memcache shell> vi php.ini configuration to `extension=memcache.so’ [available of functions, class(member functions)] - object memcache_connect( string host [, int port [, int timeout ] ]) - object memcache_pconnect( string host [, int port [, int timeout ] ]) - string memcache_get_version( object memcache ) /*** obj->getversion() ***/ - bool memcache_add( object memcache, string key, mixed var [, int flags [, int expire ] ] ) - bool memcache_set( object memcache, string key, mixed var [, int flags [, int expire ] ] ) - bool memcache_replace( object memcache, string key, mixed var [, int flags [, int expire ] ] ) - mixed memcache_get( object memcache, string key ) - bool memcache_delete( object memcache, string key, [, int flags [, int expire ] ] ) - bool memcache_debug( bool onoff ) /*** not exists member fuunction ***/ - array memcache_get_stats( object memcache ) /*** obj->getststs() ***/ - int memcache_increment( object memcache, string key [, int value ] ) - int memcache_decrement( object memcache, string key [, int value ] ) - bool memcache_close( object memcache ) - bool memcache_flush( object memcache ) [example] <?php require_once '_conf/config.php'; require_once '_lib/class.mysql.dbs.php'; require_once '_lib/class.memcache.php'; $sql = "SELECT COUNT(*) FROM avt_base_proto"; ## first, get memcache ## $mcd = new mcache; // none debug mode if($mcd->connect($_mcd['host'],$_mcd['port'])) { echo 'success connected memcached'."\n"; $foo = $mcd->get($sql); // memcached 에 있는 object 를 가져옴 } $eros = new mysql(1); // debug mode $eros->connect($_eros['host'],$_eros['user'],$_eros['pass']); $eros->select_db($_mysqldbs['meeting']); if(!$foo) { $result = $eros->query($sql); $foo = $eros->fetch_row($result); $mcd->set($sql,$foo,10); // store, TTL 10 seconds $msg = 'not'; } $eros->close(); $mcd->close(); echo "\n".$sql."\n"; echo "is $msg memcached values\n"; print_r($foo); ?>
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.