UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'aGOudc5mKZqiYyXuJeWa+IN0aqBkkJn2JUpeLCcG8Pw='
WHERE
key_id = 'a9ab3d6991a6d0bfbfd66bd18244e928eb3577a916a12b79fc7640fa984fc50c'
AND (
token = 'aGOudc5mKZqiYyXuJeWa+IN0aqBkkJn2JUpeLCcG8Pw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)