I have been experimenting with the amount of time, and revision system that helps me retain most information. The following system is currently working best for me.
1. Begin by trying to visualize what you did in the last programming session. Then check it on Anki for what you missed. (5 mins)
2. Do 30-45 mins of a course. If its a video course try to constantly guess what might come next.
3. Pause the video after a small section of writing you don't understand and try to write it from memory.
4. Hand write 5 point code summary as you go then put into Anki at the end.
Still tweaking this model but has been going well so far.