Skip to content

Instantly share code, notes, and snippets.

@tadasuke
Created May 29, 2015 08:58
Show Gist options
  • Save tadasuke/712254900216c0b33b71 to your computer and use it in GitHub Desktop.
Save tadasuke/712254900216c0b33b71 to your computer and use it in GitHub Desktop.
Memcacheでセットした値をMemcachedで取得しようとして、ハマる。 ref: http://qiita.com/tadasuke/items/dd36f4862c471d2d999f
$host = 'localhost';
$port = 11211;
$array = array( 'name' => 'tadasuke' );
// Memcacheインスタンス作成
$mem = new Memcache();
// Memcahce接続
$mem -> connect( $host, $port );
// 値をセット
$mem -> set( 'test', $array );
// セットした値を取得
$result = $mem -> get( 'test' );
// 接続解除
$mem -> close();
var_dump( $result );
array(1) { ["name"]=> string(8) "tadasuke" }
$host = 'localhost';
$port = 11211;
$array = array( 'name' => 'tadasuke' );
// Memcacheインスタンス作成
$mem = new Memcache();
// Memcahce接続
$mem -> connect( $host, $port );
// 値をセット
$mem -> set( 'test', $array );
// セットした値を取得
$result = $mem -> get( 'test' );
// 接続解除
$mem -> close();
//var_dump( $result );
// Memcahcedインスタンス作成
$memd = new Memcached();
// Memcacheに接続
$memd -> addServer( $host, $port );
// セットした値を取得
$result = $memd -> get( 'test' );
// 接続解除
$memd -> quit();
var_dump( $result );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment