I’d like to configure a Play Framework on Heroku to work with Memcached.
This thread suggests I use hard-coded config values. Heroku’s documentation states the user/password/hosts are exposed as enviornment variables … is there a way to tell Play to load these directly, without using hard-coded values?
This is what I tried:
%prod.memcached=enabled
%prod.memcached.host=%MEMCACHE_SERVERS
%prod.memcached.user=%MEMCACHE_USERNAME
%prod.memcached.password=%MEMCACHE_PASSWORD
but it doesn’t seem to work
I found a work around for you issue. In Heroku when you configure the “Memcache Add On”
it gives you the following environment variables.
but when setting the %prod.memcached.host=${MEMCACHE_SERVERS} it also needs the default port in order to operate correctly (i.e. ${MEMCACHE_SERVERS}:11211).
Therefore you can add an extra environment variable by doing the following
heroku config:add MEMCACHE_SERVER=${MEMCACHE_SERVERS}:11211in your console%prod.memcached.host=${MEMCACHE_SERVER}in your conf file—or—
figure out a way to append the port(11211) at the end of
${MEMCACHE_SERVERS}environment variable in the conf file. Which I don’t know how to do because of the “:” character will throw an exception on startup.I got the same error in play 2.x, but should work for play 1.x.