Created
May 29, 2015 08:58
-
-
Save tadasuke/712254900216c0b33b71 to your computer and use it in GitHub Desktop.
Memcacheでセットした値をMemcachedで取得しようとして、ハマる。 ref: http://qiita.com/tadasuke/items/dd36f4862c471d2d999f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Memcache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Memcached |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array(1) { ["name"]=> string(8) "tadasuke" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment