UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '8fRXZqt7wZSHeUrFZRXksv+HX+lHPunDmfhtEqCjfj8='
WHERE
key_id = 'b3047a15a9ee6becb160d2afcb694b63a31685447f7297e5406b633143ec6ca3'
AND (
token = '8fRXZqt7wZSHeUrFZRXksv+HX+lHPunDmfhtEqCjfj8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)