UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'tTTX3TJdjICAc+E5lc05nVhkfLjIw6bFpI0F3zD6I1c='
WHERE
key_id = 'beacd686b2a901ceaada85a248e17c36e68eadefeff53509a9c5f3580f117df9'
AND (
token = 'tTTX3TJdjICAc+E5lc05nVhkfLjIw6bFpI0F3zD6I1c='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)