Menyiapkan Redis sebagai Layanan yang Disediakan Pengguna
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini memandu Anda mengikat Aplikasi ke instance Redis yang tidak tercantum di marketplace Kf (termasuk Memorystore) dengan Konektor Spring Cloud Foundry. Hal ini akan menyebabkan kredensial Redis dimasukkan ke dalam Aplikasi Anda, seperti mengikat ke layanan yang disediakan melalui paket marketplace.
Sebelum memulai
Pastikan Anda telah menginstal Redis dan dapat diakses oleh cluster Kf.
Pastikan Redis telah disiapkan untuk Aplikasi Anda.
Pastikan Anda telah menargetkan Ruang yang menjalankan Aplikasi Anda.
Membuat instance yang disediakan pengguna
Agar Kf berhasil mengikat Aplikasi ke instance Redis Anda, variabel lingkungan minimum adalah URI (misalnya redis://:password@host:port). Pasangan nilai kunci tambahan dapat disertakan jika diinginkan. Contoh berikut sudah cukup untuk deployment dasar.
Mulai ulang Aplikasi Anda agar perubahan dapat diterapkan:
kfrestartapplication-name
Anda dapat mengonfirmasi bahwa variabel lingkungan baru telah disediakan ke Aplikasi Anda:
kfvcap-servicesapplication-name
Memperbarui instance yang disediakan pengguna
Jika ada perubahan pada lingkungan (misalnya, pembaruan sandi atau host di URI, atau penambahan pasangan nilai kunci baru) yang perlu diteruskan ke Aplikasi apa pun yang terikat dengannya, Anda dapat memperbarui instance yang disediakan pengguna.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Setting Up Redis as a User-Provided Service\n\n| **Note:** You can leverage services that aren't listed in the marketplace by creating user-provided service instances that an App can bind to. Learn more about [user-provided services](../concepts/user-provided-services).\n\nThis document guides you through binding your App to a Redis instance not listed in the Kf marketplace (including [Memorystore](/memorystore)) with the Spring Cloud Foundry Connector. This results in the Redis credentials being injected into your App, just like binding to services provisioned through marketplace plans.\n\nBefore you begin\n================\n\n- Ensure you have Redis installed and accessible by your Kf cluster.\n- Ensure Redis has already been set up for your App.\n- Ensure you have targeted the Space running your App.\n\nCreate the user-provided instance\n=================================\n\nFor Kf to successfully bind an App to your Redis instance, the minimum environment variable is the URI (for example `redis://:password@host:port`). Additional key-value pairs may be included if desired. The following examples should be sufficient for basic deployments.\n\nFor Redis with no AUTH configured\n---------------------------------\n\n kf cups \u003cvar translate=\"no\"\u003eservice-instance-name\u003c/var\u003e -p '{\"uri\":\"redis://\u003cvar translate=\"no\"\u003eredis-host\u003c/var\u003e:\u003cvar translate=\"no\"\u003e6379\u003c/var\u003e\"}' -t \"redis\"\n\nFor Redis with AUTH configured\n------------------------------\n\n kf cups \u003cvar translate=\"no\"\u003eservice-instance-name\u003c/var\u003e -p '{\"uri\":\"redis://:\u003cvar translate=\"no\"\u003epassword\u003c/var\u003e@\u003cvar translate=\"no\"\u003eredis-host\u003c/var\u003e:\u003cvar translate=\"no\"\u003e6379\u003c/var\u003e\"}' -t \"redis\"\n\nBind your App\n=============\n\nNow that the user-provided service has been created, you can bind your App to the instance name: \n\n kf bind-service \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e \u003cvar translate=\"no\"\u003eservice-instance-name\u003c/var\u003e\n\nRestart your App to for the changes to take effect: \n\n kf restart \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e\n\nYou can confirm the new environment variables being provided to your App: \n\n kf vcap-services \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e\n\nUpdate the user-provided instance\n=================================\n\nIf there are changes to the environment (for example password or host update in the URI, or the addition of new key-value pairs) that need to be passed on to any App bound to it, you can update the user-provided instance. \n\n kf uups \u003cvar translate=\"no\"\u003eservice-instance-name\u003c/var\u003e -p '{\"uri\":\"\u003cvar translate=\"no\"\u003enew-uri\u003c/var\u003e\", \"\u003cvar translate=\"no\"\u003esome-new-key\u003c/var\u003e\": \"\u003cvar translate=\"no\"\u003esome-new-value\u003c/var\u003e\"}'\n\n**Note:** After updating environment the service, you must unbind then rebind the service to make the changes active in your App. \n\n kf unbind-service \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e \u003cvar translate=\"no\"\u003eservice-instance-name\u003c/var\u003e\n kf bind-service \u003cvar translate=\"no\"\u003eapplication-name\u003c/var\u003e \u003cvar translate=\"no\"\u003eservice-instance-name\u003c/var\u003e\n\nRelated documents\n=================\n\n- [VCAP_SERVICES](/migrate/kf/docs/2.1/how-to/app-runtime#vcapservices)\n- [Unbind service](../cli/kf-unbind-service)\n- [Delete service](../cli/kf-delete-service)"]]