Fix #3627: Keep timed locks for more than 5 seconds

Emulated locks for Redis and Memcached now have a TTL
of 300 seconds (the default HTTP request timeout value
on many environments) and 30 attemps, each separated by
sleep(1), are made by the blocked request to try and
obtain a lock if it has been freed.

Additionaly, the blocking time for MySQL's locks,
which are also timed, is also set to 300 seconds.
4 files changed