CakeFest 2024: The Official CakePHP Conference

Memcache::getVersion

(PECL memcache >= 0.2.0)

Memcache::getVersionサーバーのバージョンを返す

説明

Memcache::getVersion(): string|false

Memcache::getVersion() は、サーバーのバージョン番号を 文字列で返します。 memcache_get_version() 関数を使用することも可能です。

パラメータ

この関数にはパラメータはありません。

戻り値

バージョン番号を表す文字列を返します。 失敗した場合に false を返します。

例1 Memcache::getVersion() の例

<?php

/* オブジェクト指向の API */
$memcache = new Memcache;
$memcache->connect('memcache_host', 11211);
echo
$memcache->getVersion();

/* 手続き型の API */
$memcache = memcache_connect('memcache_host', 11211);
echo
memcache_get_version($memcache);

?>

参考

add a note

User Contributed Notes 1 note

up
0
b dot willemsen8 at gmail dot com
9 years ago
I also use this method to verify that Memcache is properly configured on the server since it returns false if there is something wrong. So you can do something like this:

<?php
$memcache
= new Memcache;

if (
$memcache->getVersion() === false) {
throw new
Exception('Please, verify the Memcache configuration');
}
To Top