Memcached stores temporary data in memory to reduce database requests. Deploy it as a managed addon and connect your application with a Memcached client.
Keep data that you cannot lose in a persistent database. Memcached does not use persistent storage. Restarting, redeploying, pausing, upgrading, or removing an instance loses its cached data. Backups, imports, and forks are not supported.
Deploy Memcached
Authentication is optional for internal connections and disabled by default. Choose whether to enable it before creating the addon. You cannot change this choice later. Public and VPC access require both authentication and TLS.
- In your project, open Create new and select Addon.
- Select Memcached, enter a name, and choose an available version.
- In Resources, select a plan and replica count. Memcached does not require a storage allocation.
- To require credentials, go to Advanced, below Networking. Expand Memcached authentication and turn on Enable authentication.
- In Networking, configure Deploy with TLS and Accessibility. Keep Private, or select Public or VPC where available.
- Select Create addon. Wait for the addon to reach the running state before connecting your application.
If you need to change the authentication choice, create a replacement addon and update your application's connection details.
Connect to Memcached
Open the addon's connection details to get its endpoints. The internal Memcached port is 11211 over TCP. For public or VPC connections, use the endpoint and port shown for that access method.
Link the connection details to a secret group and apply it to your workload. Configure your client with the linked variables:
| Connection detail | Use |
|---|---|
HOST, PORT | Connect to one endpoint. |
HOSTS_LIST | Comma-separated host:port endpoints for multiple instances. |
TLS_ENABLED | Configure whether your client uses TLS. |
USERNAME, PASSWORD | Authenticate when authentication is enabled. |
SASL_CONNECTION_STRING | Comma-separated username:password@host:port endpoints, when authentication is enabled. |
With authentication enabled, use a client that supports SASL authentication over the binary protocol . SASL verifies the username and password. It does not encrypt traffic. If the addon uses TLS, enable TLS in your client as well.
Your client must support the selected connection format. If it does not accept SASL_CONNECTION_STRING, configure the hosts, credentials, and TLS separately.
Scale Memcached
You can change the deployment plan and increase or decrease the replica count after creation. More memory increases the space available for cached items.
Each instance has its own cache. Memcached does not replicate data between instances. Use HOSTS_LIST to give your client every instance. Configure how your client distributes keys across those servers. Refresh that list after changing the replica count.
When an instance restarts or is removed, your application must fetch missing items from the original data source. Scaling can move keys between instances, so expect missing cache items during the change.