UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'OdketgiFzgIoUUh50IdpGW314+NLq96oXXrm+mk/Q8k=' 
WHERE 
  key_id = 'f5314bdded1955aa0eecda557f77c4640f885ede8b0b1485317a40c906a5ee55' 
  AND (
    token = 'OdketgiFzgIoUUh50IdpGW314+NLq96oXXrm+mk/Q8k=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040