The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Dev Services for Redis

QuarkusはDev Servicesと呼ばれる機能をサポートしており、設定なしで様々なデータソースを作成することができます。これは実際には、dockerを実行していて、 quarkus.redis.hosts を設定していない場合、Quarkusはテストやdev-modeの実行時に自動的にRedisコンテナを起動し、自動的に接続を設定します。

Redis DevServiceをカスタマイズするために利用可能なプロパティ.

ビルド時に固定される設定プロパティ - その他の設定プロパティは実行時にオーバーライド可能です。

Configuration property

デフォルト

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present.

When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running.

Environment variable: QUARKUS_REDIS_DEVSERVICES_ENABLED

Show more

boolean

true

The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…​), use: redis/redis-stack:latest.

Environment variable: QUARKUS_REDIS_DEVSERVICES_IMAGE_NAME

Show more

string

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_REDIS_DEVSERVICES_PORT

Show more

int

Indicates if the Redis server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Redis starts a new container.

The discovery uses the quarkus-dev-service-redis label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_REDIS_DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-redis label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Redis looks for a container with the quarkus-dev-service-redis label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the quarkus-dev-service-redis label set to the specified value.

This property is used when you need multiple shared Redis servers.

Environment variable: QUARKUS_REDIS_DEVSERVICES_SERVICE_NAME

Show more

string

redis

Environment variables that are passed to the container.

Environment variable: QUARKUS_REDIS_DEVSERVICES_CONTAINER_ENV

Show more

Map<String,String>

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present.

When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_ENABLED

Show more

boolean

true

The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…​), use: redis/redis-stack:latest.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_IMAGE_NAME

Show more

string

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_PORT

Show more

int

Indicates if the Redis server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Redis starts a new container.

The discovery uses the quarkus-dev-service-redis label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-redis label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Redis looks for a container with the quarkus-dev-service-redis label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise, it starts a new container with the quarkus-dev-service-redis label set to the specified value.

This property is used when you need multiple shared Redis servers.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_SERVICE_NAME

Show more

string

redis

Environment variables that are passed to the container.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_CONTAINER_ENV

Show more

Map<String,String>

アプリケーションの本番バージョンを実行するときは、Redis接続を通常どおりに構成する必要があるため、本番データベースの構成を application.properties に含めて、引き続きDev Servicesを使用する場合は、% prod. プロファイルを使用してRedis設定を定義することをお勧めします。

Dev Services for Redisは、Dockerに依存してサーバーを起動します。お使いの環境がDockerをサポートしていない場合は、手動でサーバーを起動するか、すでに稼働しているサーバーに接続する必要があります。

Redis Stack modules (bloom, graph, search…​)を使用する場合は、image-nameに redis/redis-stack:latest

共有サーバー

ほとんどの場合、アプリケーション間でサーバーを共有する必要があります。Dev Services for Redisは、 開発 モードで動作する複数のQuarkusアプリケーションが1つのサーバーを共有するための サービスディスカバリ メカニズムを実装しています。

Dev Services for Redis は、コンテナを識別するために使用される quarkus-dev-service-redis ラベルでコンテナを起動します。

複数の(共有)サーバーが必要な場合は、 quarkus.redis.devservices.service-name 属性を設定し、サーバー名を示します。同じ値を持つコンテナを探し、見つからない場合は新しいコンテナを開始します。デフォルトのサービス名は redis です。

共有は、devモードではデフォルトで有効ですが、testモードでは無効です。 quarkus.redis.devservices.shared=false で共有を無効にすることが可能です。

関連コンテンツ