Just graduated with a master’s degree, but I internalised nothing I just graduated with a software-engineering master’s degree with a good grade from a top-five university in the UK. I also have a bachelor's in computer science.

I always revised just for exams and just enough to get that first-class degree, without actually learning anything. I basically revise for the exam itself, by looking at past paper answers, and I never study the actual material. I then forget everything after finishing the exam. I've been repeating this cycle since school.
This method has given me a great first-class degree but with practically zero knowledge. As @Sule said, I never internalised the material.
I also never did a single internship because I didn’t need to.

Now, I’m facing a problem: How am I supposed to find work if I barely know how to program? Will employers just accept me because I have a fancy software-engineering master’s degree from a top-five university? I also haven’t worked professionally a single day in my life.

I'm thinking of getting a PhD at this point.
You asked,


  How am I supposed to find work if I barely know how to program?


It sounds like you're looking for a job in industry, versus academia, so I will answer from that perspective.

Employers are generally looking for people who can get things done and will consider the ability to program as a means to an end. While technical skills (i.e. mastery of a specific programming language) will be important, it's never the only factor evaluated, and it's sometimes not even the most important factor. Combine that with the pace at which technology develops, and having a specific technical skill ends up becoming even less important, as that skill may be obsolete rather quickly. Go find a dozen software engineers who have been working in industry for a decade or more since getting a degree, and ask if they're still using the actual content from any of their classes. You may be surprised at the answers. What they will probably talk about is how valuable it was to become a "learning machine" rather than a knowledge repository.

You've described the process you used to get good marks on tests. That's a valuable skill. Employers don't inherently care about test scores, but they will care about someone who can pick something up, and learn it well enough to complete a task. In many programming environments, the ability to learn something, apply it, and then move on to the next thing is incredibly valuable - even if you "forget" that thing as you're picking up future things. 

Further, Resumes and interviews are sales tools - you're selling yourself to an employer. Focus on the value you can add and match that value to their needs. There's a job out there for everyone - don't just spam every software job you see and hope one sticks despite your shortcomings - instead, focus on understanding your own strengths and then look for jobs where your strengths are a good fit. Write your resume to emphasize the skills you do have and be ready to talk about them in interviews. 

Taking a bit of a tangent, there's a concept in motorcycling called "target fixation." Riding instructors working with new riders will emphasize the skill of looking where you want to go when in a difficult situation. This is because new riders who are surprised by a piece of road debris, or a vehicle out of place, tend to focus on that thing to the extent that the ride right into it instead of avoiding it. Apply that to yourself since you're undertaking the new pursuit of searching for a job: Don't become fixated on what you perceive as weaknesses or you may end up in a mindset where all you have to offer in an interview is nervousness about what you see as your own shortcomings.

As a final point, to address your comment of,


  I also haven't worked professionally a single day in my life


I have a feeling that the quicker you can change that, the less significant your problem will seem. Once you have a few years of work experience, you will see life through a different lens - on the one hand, you probably don't want a menial job for the rest of your life, but on the other hand, your first job doesn't have to be the job - it's OK to just take a job and get some experience to give you some confidence and expose yourself to a professional workplace.