UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'wU517LSN6hda3HylN4n3uxQcubDWoZ2ozodoCDcOVOs=' 
WHERE 
  key_id = '4945b33b4b9ae99c26fcc2990a2502f73a586a3a71d34cadc106f4f09d766ca4' 
  AND (
    token = 'wU517LSN6hda3HylN4n3uxQcubDWoZ2ozodoCDcOVOs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034