Question

How to use memcached in the app platform?

Posted May 4, 2021 981 views
CachingDjangoDigitalOcean App Platform

I am trying to figure out the best alternative to use some sort of memory caching for a Django application with a postgress database deployed on DigitalOcean App Platform.

I cannot see any documentation of how to include memcached or any other in-memory management tool as part of the App Platform deployment.

Any Ideas will be appreciated

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @mariorossell
Memcached is an in-memory data storage system. You can run Memcached as an internal service in the App Platform. It is an internal service therefore there will be no HTTP route or PORT set.

A sample code for a Memcached service can be seen like below

Sample Code for Memcached internal service
- name: library-memcached
  image:
    registry: library
    registry_type: DOCKER_HUB
    repository: memcached
    tag: latest
  instance_count: 1
  instance_size_slug: basic-xs
  internal_ports:
    - 11211

Other services can access the Memcached service using <servicename>:<internal_ports> like below for the above sample Memcached service.

  • library-memcached:11211

After successful deployment, to connect other services with Memcached service, run the below command in the service console from whom you want to connect Memcached with.

  • telnet library-memcached 11211

Note: App Platform instances are ephemeral and can be redeployed at any time which would cause the contents of the Memcached server to be lost.

Other than Memcached for in-memory data storage, we also provide Redis as a managed database in the Digital Ocean. You can view the below links for information related to how to create Redis Database and how to manage databases in the App Platfrom.

Redis Database in Digital Ocean
How to manage Database in App Platform link