UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'uROfuav3Rdiegh8RndwknQHu+z44lFVVUFjZ05WUBQs=' 
WHERE 
  key_id = 'a5015d1a7062be91b4ef57a9ac94166f676a6f7d4a255fe5d5d1e7d5a2170658' 
  AND (
    token = 'uROfuav3Rdiegh8RndwknQHu+z44lFVVUFjZ05WUBQs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038