UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ozWTAFMggYn+68qpyhx8hAn22eZntqqx20cM10AWdv8='
WHERE
key_id = 'd1797779c1be505ea8f8d009f487c4b1b26a10aef9d612853a7ce0e0fc73fa39'
AND (
token = 'ozWTAFMggYn+68qpyhx8hAn22eZntqqx20cM10AWdv8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)