UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'O1f71NOz+/pDyhleDVHcAEXqcCgbEQLUfzoyoA2mOJ8='
WHERE
key_id = '31fffb5d9e816844571b9472bef45ec09d167aa1ab810b4aa5ca5ac9fcb82239'
AND (
token = 'O1f71NOz+/pDyhleDVHcAEXqcCgbEQLUfzoyoA2mOJ8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)