async def METHOD_NAME(self, cache_name: str, key: str, value: Any, expiry_ms: int) -> None:
    """Add the key/value to the named cache, with the expiry time given."""
    if self._redis_connection is None:
        return
    set_counter.labels(cache_name).inc()
    # txredisapi requires the value to be string, bytes or numbers, so we
    # encode stuff in JSON.
    encoded_value = json_encoder.encode(value)
    logger.debug("Caching %s %s: %r", cache_name, key, encoded_value)
    with opentracing.start_active_span(
        "ExternalCache.set",
        tags={opentracing.SynapseTags.CACHE_NAME: cache_name},
    ):
        with response_timer.labels("set").time():
            return await make_deferred_yieldable(
                self._redis_connection.METHOD_NAME(
                    self._get_redis_key(cache_name, key),
                    encoded_value,
                    pexpire=expiry_ms,
                )
            )