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