Memorisation, whether it’s totally committing something to memory, or used to help with (sight) reading tricky music, can be seen as two almost separate techniques:
Randomness and patterns.
Memorising random bits of information is the hardest, for example if you can’t speak English, memorising a sentence is difficult because it’s just a collection of different words, but if you speak the language, it’s much easier.
There are various tricks to memorising random events, e.g. the “memory palace” or method of loci. This can be applied to musical phrases but involves you being able to use visualisation. On a very simple level you might equate a minor sounding phrase with sadness or wistfulness or give it a colour.
The main trick though is being able to establish patterns.
The same skills you need as a composer or improviser works in reverse when analysing: in a long phrase, look for repetitions, or adaptations.
To do this you must first have a thorough grounding in music theory.
So in the key of C you might have the simple phrase C D E G. You need to think immediately 1,2,3 5 in the tonic. Then 2 bars later there is E F# G# B. You should immediately know this is the same phrase transposed up a major 3rd. Or if the phrase is E F G B, you immediately know it’s transposed up but sticks to the C diatonically.
These things can also be on a more abstract level, it might just be a repetition of the melodic “contour”. Even if the notes themselves don’t fit into a pattern, at least by recognising the pattern of a repeated contour, you are making it slightly less random.
The same applies to rhythm. The notes might not fit into a previous pattern, but if a rhythm is repeated, or repeated with an embellishment, again you are taking out some of the randomness and making memorisation a bit easier.