UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'g9FiwbJs2MplnbmNsCyPtWgdO0H6ohZfUAwC0whQ354='
WHERE
key_id = 'cfdf8eca31821c9ee840022709e8647181b2927723868c369d8551eddc15a76b'
AND (
token = 'g9FiwbJs2MplnbmNsCyPtWgdO0H6ohZfUAwC0whQ354='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)