Well, there are basically two approaches. And programming gives you a third:
1) If it is a real book, and it is yours, you can use a yellow marker to highlight the key parts of each page. To freshen your knowledge, you then just have to re-read the key parts of each page.
2) You can make a short (best if less than 1 page) summary after each chapter or other logical unit. So just read the entire chapter, then sit down and summarize it in your own words. Usually this helps you retain the knowledge better than with the first approach, though it takes a little more time.
3) Lastly, as this is a programming book, I usually do a variant of approach 2. I don't write a summary of the chapter, but make an short, working, piece of example code with comments showing the key features from the language introduced in that chapter (the example code can be a nonsense program). So when I then need to do some programming, I can just browse to my example file on hashes, for example, and copy & paste some working code from there that I wrote while reading the book.
The third approach really pays of if you learn multiple programming languages. You have to give less and less example code and comments to capture the knowledge from each chapter, as you already know key programming concepts from previous languages.