Made memcache locking during transaction more robust.

This mitigates a subtle transaction edge case where memcache locks might
expire before a transaction has been committed. This is because
transactions can last 60 seconds and locks last 32 seconds. Now memcache
locks are executed as a transaction is being applied.