PHP 5 はサポートが終了しており、2026 年 1 月 31 日に
非推奨になります。非推奨になると、過去に組織のポリシーを使用して以前のランタイムのデプロイを再度有効にしていた場合でも、PHP 5 アプリケーションをデプロイできなくなります。既存の PHP 5 アプリケーションは、
非推奨になる日付以降も引き続き実行され、トラフィックを受信します。
サポートされている最新バージョンの PHP に移行することをおすすめします。
Memcache の使用方法
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このページでは、 Google Cloud コンソールを使用してアプリケーションの Memcache サービスを構成、モニタリングする方法について説明します。また、App Engine Memcache PHP API を使用して、キャッシュされる値を設定および取得する方法についても説明します。Memcache については、Memcache の概要をご覧ください。
Memcache を構成する
- Google Cloud コンソールの [Memcache] ページに移動します。
[Memcache] ページに移動
使用する Memcache サービスレベルを選択します。
- 共有(デフォルト) - 無料で、ベスト エフォート ベースでキャッシュ容量を提供します。
- 専用 - キャッシュ サイズ使用量の GB 時間で請求され、アプリケーションに対して固定キャッシュ容量が独占的に割り当てられます。
使用可能なサービスクラスについては、Memcache の概要をご覧ください。
値のキャッシュへの保存と取得
値をキャッシュに保存する
Memcache::set
を使用してキーの値を追加します。
キャッシュに保存された値を検索する
単一のキーの値を検索するには、Memcache::get
を使用します。
Google Cloud コンソールで Memcache をモニタリングする
- Google Cloud コンソールの [Memcache] ページに移動します。
[Memcache] ページに移動
- 次のレポートを調べます。
- Memcache サービスレベル: アプリケーションが共有または専用のどちらのサービスレベルを使用しているかを示します。プロジェクトのオーナーの場合は、2 つのサービスレベルを切り替えることができます。詳細については、サービスレベルをご覧ください。
- ヒット率: キャッシュから提供されたデータ リクエストのパーセンテージと、そのデータ リクエストの実数が表示されます。
- キャッシュ内のアイテム。
- 最も古いアイテムの経過期間: 最も古いキャッシュされたアイテムの経過期間。アイテムの経過時間は使用(読み取りまたは書き込み)されるたびにリセットされます。
- 総キャッシュ サイズ。
次の操作を行うことができます。
- 新しいキー: 新しいキーをキャッシュに追加します。
- キーを検索: 既存のキーを取得します。
- キャッシュをフラッシュ: キャッシュからすべてのキーと値のペアを削除します。
(専用 Memcache のみ)ホットキーのリストを参照します。
- 「ホットキー」は Memcache 内の 100 クエリ/秒(QPS)以上を受信するキーです。
- このリストには QPS の高い順で並べ替えられた最大 100 個のホットキーが含まれます。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-04 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eThis page guides users on configuring and monitoring the memcache service for applications using the Google Cloud console, as well as utilizing the App Engine Memcache PHP API for caching.\u003c/p\u003e\n"],["\u003cp\u003eMemcache offers two service levels, Shared and Dedicated, with the former being free and the latter providing a fixed, billed cache capacity.\u003c/p\u003e\n"],["\u003cp\u003eUsers can cache values using \u003ccode\u003eMemcache::set\u003c/code\u003e and retrieve cached values using \u003ccode\u003eMemcache::get\u003c/code\u003e via the App Engine Memcache PHP API.\u003c/p\u003e\n"],["\u003cp\u003eThe Google Cloud console allows for monitoring of the memcache service level, hit ratio, cache items, oldest item age, and total cache size, and offers actions like adding, finding, or flushing keys.\u003c/p\u003e\n"],["\u003cp\u003eDedicated memcache provides a hot key list for keys that receives more than 100 queries per second.\u003c/p\u003e\n"]]],[],null,["# Using Memcache\n\nThis page describes how to configure and monitor the memcache service for your\napplication using the Google Cloud console. It also describes how to use the\nApp Engine Memcache PHP API to set and retrieve cached values. To learn more about memcache,\nread the [Memcache Overview](/appengine/docs/legacy/standard/php/memcache).\n\n\u003cbr /\u003e\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-differences) to learn about your migration options for legacy bundled services.\n\nConfiguring memcache\n--------------------\n\n1. Go to the Memcache page in the Google Cloud console. \n [Go to the Memcache page](https://console.cloud.google.com/appengine/memcache)\n2. Select the memcache service level you want to use:\n\n - **Shared** (default) - free and provides cache capacity on a best-effort basis.\n - **Dedicated** - billed by the GB-hour of cache size and provides a fixed cache capacity assigned exclusively to your application.\n\n Learn more about available service classes in [Memcache Overview](#service_levels).\n\nCaching and retrieving values\n-----------------------------\n\n### Caching a value\n\nUse [`Memcache::set`](http://php.net/manual/en/memcache.set.php) to add a key's\nvalue: \n\n $memcache = new Memcache;\n $value = $request-\u003egetContent();\n return $memcache-\u003eset($key, $value);\n\n### Looking up cached values\n\nUse [`Memcache::get`](http://php.net/manual/en/memcache.get.php) to look up the\nvalue of a single key: \n\n $memcache = new Memcache;\n return $memcache-\u003eget($key);\n\nMonitoring memcache in the Google Cloud console\n-----------------------------------------------\n\n1. Go to the Memcache page in the Google Cloud console. \n [Go to the Memcache page](https://console.cloud.google.com/appengine/memcache) \n2. Look at the following reports:\n - **Memcache service level** : Shows if your application is using the Shared or Dedicated service level. If you are an owner of the project, you can switch between the two. Learn more about the [service levels](./#service_levels).\n - **Hit ratio**: Shows the percentage of data requests that were served from the cache, as well as the raw number of data requests that were served from the cache.\n - **Items in the cache**.\n - **Oldest item age**: The age of the oldest cached item. Note that the age of an item is reset every time it is used, either read or written.\n - **Total cache size**.\n3. You can take any of the following actions:\n\n - **New key**: Add a new key to the cache.\n - **Find a key**: Retrieve an existing key.\n - **Flush cache**: Remove all the key-value pairs from the cache.\n4. (Dedicated memcache only) Look through the list of **Hot keys**.\n\n - \"Hot keys\" are keys that receive more than 100 queries per second (QPS) in the memcache.\n - This list includes up to 100 hot keys, sorted by highest QPS.\n\nWhat's next\n-----------\n\n- Learn more about memcache in the [Memcache Overview](/appengine/docs/legacy/standard/php/memcache).\n- Refer to the documentation for the [Memcache](http://php.net/manual/en/book.memcache.php) and [Memcached](https://php.net/manual/en/book.memcached.php) APIs."]]