Readouble

Laravel 5.dev Redis

イントロダクションIntroduction

Redisはオープンソースの進歩的なキー・値保存システムです。キーに文字列ハッシュリストセットソート済みセットが使用できるため、データ構造サーバーとしてしばしば取り上げられます。Redis[http://redis.io] is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings[http://redis.io/topics/data-types#strings], hashes[http://redis.io/topics/data-types#hashes], lists[http://redis.io/topics/data-types#lists], sets[http://redis.io/topics/data-types#sets], and sorted sets[http://redis.io/topics/data-types#sorted-sets].

RedisをLaravelで使いはじめる前に、Composerによりpredis/predisパッケージ(~1.0)をインストールする必要があります。Before using Redis with Laravel, you will need to install the predis/predis package (~1.0) via Composer.

注意: PECLでRedis PHP拡張をインストールしている場合、config/app.phpファイルのRedisエイリアスをリネームする必要があります。Note: If you have the Redis PHP extension installed via PECL, you will need to rename the alias for Redis in your config/app.php file.

設定Configuration

アプリケーションのRedis設定はconfig/database.phpファイルにあります。このファイルの中にredis配列があり、アプリケーションで使用されるRadisサーバーの設定を含んでいます。The Redis configuration for your application is stored in the config/database.php file. Within this file, you will see a redis array containing the Redis servers used by your application:

'redis' => [

	'cluster' => true,

	'default' => ['host' => '127.0.0.1', 'port' => 6379],

],

デフォルトサーバー設定は、開発時には十分でしょう。ですが、ご自由に自分の環境に合わせてこの配列を変更してください。ただ各Redisサーバーに名前を与え、使用するホストとポートを指定するだけです。The default server configuration should suffice for development. However, you are free to modify this array based on your environment. Simply give each Redis server a name, and specify the host and port used by the server.

clusterオプションはLaravel Redisクライアントに対し、Redisノード間でクライアントサイドで共有することを伝えます。これによりノードをプールしたり、利用できるRAMの大きさのキャッシュが利用できます。しかし注意すべきなのは、クライアントサイドの共有ではフェイルオーバーが処理されないことです。ですから主な使い方はキャッシュデーターを他のプライマリーのデーター域から使用できるようにすることでしょう。The cluster option will tell the Laravel Redis client to perform client-side sharding across your Redis nodes, allowing you to pool nodes and create a large amount of available RAM. However, note that client-side sharding does not handle failover; therefore, is primarily suited for cached data that is available from another primary data store.

Redisサーバーが認証を求めている場合、Redisサーバー設定にpasswordキー/値のペアを指定してください。If your Redis server requires authentication, you may supply a password by adding a password key / value pair to your Redis server configuration array.

使用法Usage

Redis::connectionメソッドを呼び出すだけで、Redisインスタンスが取得されます。You may get a Redis instance by calling the Redis::connection method:

$redis = Redis::connection();

これによりデフォルトのRedisサーバーのインスタンスが取得できます。もしサーバーをクラスタ化していない場合、Redis設定で定義されている特定のサーバーを取得するには、connectionメソッドにサーバー名を渡す必要があります。This will give you an instance of the default Redis server. If you are not using server clustering, you may pass the server name to the connection method to get a specific server as defined in your Redis configuration:

$redis = Redis::connection('other');

一度Redisクライアントのインスタンスを取得すれば、どんなRedisコマンドでも、発行できます。LaravelではコマンドをRedisサーバーに渡すため、マジックメソッドが使用できます。Once you have an instance of the Redis client, we may issue any of the Redis commands[http://redis.io/commands] to the instance. Laravel uses magic methods to pass the commands to the Redis server:

$redis->set('name', 'Taylor');

$name = $redis->get('name');

$values = $redis->lrange('names', 5, 10);

コマンドへの引数はシンプルにマジックメソッドに渡されていることに注目してください。もちろんマジックメソッドを使用したくなければ、サーバーにコマンドを送信するためcommandメソッドを使用できます。Notice the arguments to the command are simply passed into the magic method. Of course, you are not required to use the magic methods, you may also pass commands to the server using the command method:

$values = $redis->command('lrange', array(5, 10));

コマンドをデフォルト接続に対し実行吸う場合は、静的なマジックメソッドをRedisクラスに対し使用してください。When you are simply executing commands against the default connection, just use static magic methods on the Redis class:

Redis::set('name', 'Taylor');

$name = Redis::get('name');

$values = Redis::lrange('names', 5, 10);

注目: RadisのキャッシュセッションドライバーはLaravelに含まれています。Note: Redis cache[/docs/master/cache] and session[/docs/master/session] drivers are included with Laravel.

パイプラインPipelining

パイプラインは多くのコマンドを一度にサーバーへ送る必要がある時に使用すべきです。使用を開始するにはpipelineコマンドを使ってください。Pipelining should be used when you need to send many commands to the server in one operation. To get started, use the pipeline command:

多くのコマンドをサーバーに送るPiping Many Commands To Your Servers

Redis::pipeline(function($pipe)
{
	for ($i = 0; $i < 1000; $i  )
	{
		$pipe->set("key:$i", $i);
	}
});

章選択

Artisan CLI

設定

明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

Pagination和文
ペジネーション
ペギネーション
ページネーション
ページ付け
Scaffold和文
スカフォールド
スキャフォールド
型枠生成
本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作