An Optimal Knowledge Retention Framework for Continual Learning in Data Stream Scenarios