Was using Memcache and Memcached extensions, painfully bouncing between faults, failures and shortcomings of each. My two cents: Neither of these old drivers has been a smash hit, repressing and slowly dooming of the true potential and full use of unix memcached.
The pain finally drove to me to try APC's apc_store and apc_fetch. The results? Instant success, no more errors, an order of magnitude (at least) speed boost, plus one less thing (memcached) to run. Nice. Never going back again. Thank y'all.
Alternative PHP Cache
- 導入
- インストール/設定
- 定義済み定数
- APC 関数
- apc_add — 新規の変数をデータ領域にキャッシュする
- apc_bin_dump — 指定したファイルおよびユーザー変数のバイナリダンプを取得する
- apc_bin_dumpfile — キャッシュされたファイルやユーザー変数のバイナリダンプをファイルに出力する
- apc_bin_load — バイナリダンプを APC のファイル/ユーザーキャッシュに読み込む
- apc_bin_loadfile — バイナリダンプをファイルから APC のファイル/ユーザーキャッシュに読み込む
- apc_cache_info — APC のデータから、キャッシュされた情報を取得する
- apc_cas — 古い値を新しい値に更新する
- apc_clear_cache — APC キャッシュをクリアする
- apc_compile_file — ファイルをバイトコードキャッシュに保存し、すべてのフィルタをバイパスする
- apc_dec — 保存した数値を減らす
- apc_define_constants — 定数の組を定義し、それを取得あるいは一括定義する
- apc_delete_file — ファイルを opcode キャッシュから削除する
- apc_delete — 格納されている変数をキャッシュから取り除く
- apc_exists — APC キーが存在するかどうかを調べる
- apc_fetch — 格納されている変数をキャッシュから取得する
- apc_inc — 保存した数値を増やす
- apc_load_constants — 定数群をキャッシュから読み込む
- apc_sma_info — APC の共有メモリ割り当てに関する情報を取得する
- apc_store — 変数をデータ領域にキャッシュする
- APCIterator — APCIterator クラス
- APCIterator::__construct — APCIterator イテレータオブジェクトを作成する
- APCIterator::current — 現在の項目を取得する
- APCIterator::getTotalCount — 総数を取得する
- APCIterator::getTotalHits — キャッシュヒットの総数を取得する
- APCIterator::getTotalSize — キャッシュのサイズの合計を取得する
- APCIterator::key — イテレータのキーを取得する
- APCIterator::next — ポインタを次の項目に移動させる
- APCIterator::rewind — イテレータを巻き戻す
- APCIterator::valid — 現在位置が有効かどうかを調べる
mike at eastghost dot com ¶
1 year ago
umut dot kirgoz at gmail dot com ¶
1 year ago
Since APC 3.1.3, there is a bug (http://pecl.php.net/bugs/bug.php?id=16814) which produces warnings like "Potential Cache Slam Averted for Key" when slam defense is on and you're trying to write a key that already exists.
These is not a fix right now for this, but you can change the APC settings from php.ini file like below if possible:
apc.write_lock = 1
apc.slam_defense = 0
hello at haroonahmad dot co dot uk ¶
3 years ago
Disclaimer: i do not guarantee it will work for you so you better use it at your own risk. It works for me.
* I am using # symbol for all shell commands
I am posting a quick step-by-step guide to install APC on servers (dedicated or VPS) with cpanel/whm working.
First login as a root to your server/vps and make a directory to work with this plugin,
#mkdir /home/APC-php
#cd /home/APC-php
now here we will first download the APC with following command
#wget http://pecl.php.net/get/APC-3.0.14.tgz
you can check for the latest version
now you can use gzip and tar separately or tar -xzvf to unzip this file
#tar -xzvf APC-3.0.14.tgz
now you will have a APC-3.0.14 folder.
#cd APC-3.0.14
now you have to make php configuration files by following command
#phpize
after this use following three commands
# ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
*if you do not know the php path then execute ( which php ) command it will display the path. on a typical cpanel vps it could be /usr/bin/php-config or /usr/local/bin/php-config but you better check it before executing the above command)
#make
#make test
#make install
NOTE: if you are using suPHP then skip --with-apxs
*one more thing, if you use
#make test
command it shows 3 tests failed then do not worry, it showed at least to me but worked with the final steps.
the (make install) command will return the apc.so module path, note down that with you as you will have to feed it in the php.ini file in the next step.
check your php.ini location by
#php -i | grep php.ini
then open it with your favorite editor. mine was at
#vi /usr/local/lib/php.ini
and go to the last line and paste the following
extension="apc.so"
now there is a catch in it, if you have other modules installed and their extension directory is different than the one MAKE INSTALL showed for APC so you have to move your apc.so to that directory so that all modules are in the same directory. in my case my APC directory was
/usr/lib/php/extensions/no-debug-non-zts-20060613/
but i moved apc.so from this location to my other location where my other extensions.so files were.
you can check that path in php.ini sectiion of
extension_dir = ""
after this restart your apache, for different servers it may vary mine worked with
#service httpd restart
if everything works fine it will restart apache without showing any error. in case of any error, roll back your php.ini changes and restart apache and discuss your problem in some forum or email me at hello@haroonahmad.co.uk
now check the phpinfo() output in your browser and it will display APC version information etc. for command line you might do
php -i | grep apc
I hope it helps.
Haroon Ahmad
bugzilla33 at gmail dot com ¶
2 years ago
Attention:
APC 3.1.4 does not work with files in PHAR archives.
phar:// stream wrappers including by require funcion are not cached.
