Dumbledore explains to Harry in Half-Blood Prince that out of all the Horcruxes, the diary is both a Horcrux and a weapon. Not only did it store a portion of Voldemort's soul, but it had the ability to allow Voldemort to possess others, to make emotional connections with another, and to lead them to open the Chamber of Secrets.

‘Hello, Harry Potter. My name is Tom Riddle. How did you come by my diary?’

These words, too, faded away, but not before Harry had started to scribble back.

‘Someone tried to flush it down a toilet.’ He waited eagerly for Riddle’s reply.

‘Lucky that I recorded my memories in some more lasting way than ink. But I always knew that there would be those who would not want this diary read.’

‘What do you mean?’ Harry scrawled, blotting the page in his excitement.

‘I mean that this diary holds memories of terrible things . . .'

How did Tom Riddle infuse the diary with his own memories? (I realize that Tom Riddle used a quill and ink to write the words into the diary; what I'm asking is how the memories became embedded in the diary, and how they remained sentient.). As the quote says, the memories were infused into the diary in a "more lasting way than ink" -- what kind of magic would enable this to happen?

I don't think Dumbledore said the diary was the only Horcrux that was also a weapon. (Recall that the ring was also a weapon, or at least booby-trapped; and the locket was working its way into their psyches, and would have done much more damage if they hadn't been taking turns with it.) He was just saying that other wizards usually hid their Horcruxes away, and the fact that the diary was also a weapon was the first thing that made Dumbledore suspect that Voldemort had multiple Horcruxes.
– Joe WhiteDec 19 '12 at 13:26

5

Here's what he said: "A mere memory starting to act and think for itself? A mere memory, sapping the life out of the girl into whose hands it had fallen? No, something much more sinister had lived inside that book ... a fragment of soul, I was almost sure of it. The diary had been a Horcrux. But this raised as many questions as it answered. What intrigued and alarmed me most was that that diary had been intended as a weapon as much as a safeguard." So, yeah, I do see your point.
– SlytherincessDec 19 '12 at 19:55

How do you know a 'soul' in the Hard Potter world contains memories?
– AncientSwordRage♦Dec 18 '12 at 19:03

3

Why wouldn't it? Voldemort's "primary" soul fragment retained its memories. Given that the fragment of soul in the diary seemed to be sentient, I think the most likely explanation is that it retained its memories.
– Kevin♦Dec 18 '12 at 19:39

3

Then why didn't Harry have all of Voldemort's memories?
– SlytherincessDec 18 '12 at 22:02

8

@Slytherincess the diary itself didn't have the memories, the piece of soul did. Similarly, Harry didn't have Voldemort's memories, but the piece of Voldemort's soul may have retained them nonetheless. Just because Harry couldn't access them doesn't mean they weren't there.
– Kevin♦Dec 18 '12 at 22:17

Voldemort placed his memories inside the diary alongside his soul when he turned it into a Horcrux.

This has nothing to do with Pensieve. The confusion is created because Voldemort is the one who describes the diary as a book of memories. Voldemort, naturally, was very secretive about his Horcruxes and would never name a Horcrux for what it really is under any circumstances. Consequently, Riddle describes the diary as a memory bank. It was actually an alert and living soul piece which had access to Lord Voldemort's memory and life experiences at the moment the Horcrux was created. Kevin makes this point but I thought I'd add a longer answer to explain why exactly this is the case.

We see from the locket in Deathly Hallows that soul pieces in Horcruxes are not dormant, static objects which wait silently in storage. Rather, they are living and listening spirits which respond to what's happening around them.

Ron passed the Horcrux to Harry. After a moment or two, Harry thought he knew what Ron meant. Was it his own blood pulsing through his veins that he could feel, or was it something beating inside the locket, like a tiny metal heart?(Deathly Hallows, Chapter 14, The Thief).

Harry became aware of the locket against his skin; the thing inside it that sometimes ticked or beat had woken; he could feel it pulsing through the cold gold. Did it know, could it sense, that the thing that would destroy it was near?(Deathly Hallows, Chapter 17, Bathilda's Secret).

Then something tightened around his neck. He thought of water weeds, though nothing had brushed him as he dived, and raised his empty hand to free himself. It was not weed: the chain of the Horcrux had tightened and was slowly constricting his wind pipe.(Deathly Hallows, Chapter 19, The Silver Doe).

The soul piece in the Horcrux is audible, beats faster when excited and is even able to attempt executions. The locket-Horcrux replicates the character and personality of the man whose soul it contains. Voldemort is cruel and manipulative, and therefore so is the locket.

Then a voice hissed from out of the Horcrux.
"I have seen your heart, and it is mine."
"Don't listen to it!" Harry said harshly. "Stab it!"
"I have seen your dreams, Ronald Weasley, and I have seen your fears. All that you desire is possible, but all that you fear is also possible..."
"Stab!" shouted Harry; his voice echoed off the surrounding trees, the sword point trembled, and Ron gazed down into Riddle's eyes.
"Least loved, always, by the mother who craved a daughter...least loved, now, by the girl who prefers your friend...second best, always, eternally over-shadowed..."(Deathly Hallows, Chapter 19, The Silver Doe).

The locket speaks with Riddle's voice and contains Riddle's eye because it contains a piece of Riddle. During this scene it proves its sentience. It speaks, it channels Harry and Hermione and it even bursts out of the confines of its object to become a physical apparition.

Out of the locket's two windows, out of the eyes, there bloomed, like two grotesque bubbles, the heads of Harry and Hermione, weirdly distorted.
Ron yelled in shock and backed away as the figures blossomed out of the locket, first chests, then waists, then legs, until they stood in the locket, side by side like trees with a common root...(Deathly Hallows, Chapter 19, The Silver Doe).

In other words, the locket-Riddle behaves and acts remarkably like the diary-Riddle. On both cases, neither of them are exactly memories. Both of them are soul-fragments. They live, they wait, they prey and - when powerful enough and when the circumstances allow - they speak and break out of the confines of their Horcrux. The trigger for this in the case of the locket was Harry opening the locket through Parseltongue. The trigger in the case of the diary was Ginny pouring enough of her soul into the diary that Riddle was strong enough to leave.

"But there isn't much life left in her: she put too much into the diary, into me. Enough to let me leave its pages at last."(Chamber of Secrets, Chapter 17, The Heir of Slytherin).

The abilities that diary-Riddle had to write back, to coerce, to trick, to lie, to pressure and to step out of the diary stemmed from his nature as a soul fragment. The magic that powered him was the magic of Horcruxes, not any spells related to memory, Pensieve or any other branch of magic. Riddle states this directly: it was himself that he put in the diary, not a spell.

"I decided to leave behind a diary, preserving my sixteen year-old self in its pages, so that one day, with luck, I would lead another in my footsteps, and finish Salazar Slytherin's famous work."(Chamber of Secrets, Chapter 17, The Heir of Slytherin).

Note that he says he put his "self" in the diary, not just his memories.

It is the sixteen year-old Riddle that lives in the diary, and so that particular soul fragment contained the memories of the sixteen year-old Riddle. Consequently, he can take Harry inside his recollection of the capture of Hagrid. It's far more than memory which is in the diary, however. It's Voldemort himself. This is true of all the Horcruxes.

Is that to say that the diary was no different then than all the other Horcruxes? No. As the question rightly states, the diary was different insofar as it was a weapon, not just a soul-container.

"What intrigued and alarmed me most was that the diary had been intended as a weapon as much as a safeguard."
"I still don't understand," said Harry.
"Well, it worked as a Horcrux is supposed to work - in other words, the fragment of soul concealed inside was kept safe and had undoubtedly played its part in preventing the death of its owner. But there could be no doubt that Riddle really wanted that diary read, wanted the piece of soul to inhabit or possess somebody else, so that Slytherin's monster would be unleashed again."(Half-Blood Prince, Chapter 23, Horcruxes).

The nature of the diary meant that it could possess people and communicate with people in a way in which the other Horcruxes couldn't.

As I've already said, the diary was not different in its ability to be sentient, to speak, to be coercive or to break free from the confines of its object. All the Horcruxes could do this, given the right circumstances. But the diary was not only intended to be read, it was intended to be interacted with. A diary is interactive in a way in which a locket, a ring, a diadem, a snake and a cup really aren't. This meant that it not only fed on the negativity and ill-feeling of those around it, as the locket did; it also sapped the souls of those who wrote in it, weakening them so that possession is possible.

"So Ginny poured out her soul to me, and her soul happened to be exactly what I wanted. I grew stronger and stronger on a diet of her deepest fears, her darkest secrets. I grew powerful, far more powerful than little Miss Weasley. Powerful enough to start feeding Miss Weasley a few of my secrets, to start pouring a little of my soul back into her..."(Chamber of Secrets, Chapter 17, The Heir of Slytherin).

It is the unique nature of the diary as the means of opening the Chamber of Secrets and as a method of communication which enables possession which seperates it from the other Horcruxes. It's important to understand this distinction to see that it wasn't some extra, unknown magic which gave diary-Riddle the powers he had. He was a Horcrux like any other. But because the object which he was placed in was a diary he was able to sap the souls of anyone who wrote in him, unlike the other Horcruxes. But his memories, his nature and the magic that sustained him was Horcrux-magic, just as it was for the other Horcruxes.

In conclusion, the method "more lasting than ink" by which Riddle retained his memories was through creating Horcruxes. Riddle not only put his memories in the diary, he poured in his very self. The soul fragment in the diary acted autonomously, as all the others did. And it had access to Riddle's memories, as all the others did. The diary could possess people whereas the others couldn't because they were not designed for possession. But in every other respect the diary and the other Horcruxes were exactly alike.

As great as this answer is at explaining how the diary worked, it does not actually answer the OP. Specifically "How did Tom Riddle infuse the diary with his own memories?". Or did I miss it? If not, can you add it?
– amflareDec 14 '17 at 4:43

@amflare The memories went in alongside the soul fragment when the Horcrux was made. Hopefully the title and end paragraph make this clear, although I did get a little carried away with detail in the middle so maybe my point got lost.
– The Dark LordDec 14 '17 at 13:30

"A memory," said Riddle quietly. "Preserved in a diary for fifty
years."

From the Goblet of Fire, where Harry used Dumbledore's Pensieve for the first time (and actually met the same magic before):

Once before, Harry had found himself somewhere that nobody could see
or hear him. That time, he had fallen through a page in an enchanted
diary, right into somebody else's memory... and unless he was very
much mistaken, something of the sort had happened again...

JKR herself said this about a Pensieve:

Rowling: Yeah. Otherwise it really would just be like a diary,
wouldn't it? Confined to what you remember. But the Pensieve recreates
a moment for you, so you could go into your own memory and relive
things that you didn't notice the time. It's somewhere in your head,
which I'm sure it is, in all of our brains. I'm sure if you could
access it, things that you don't know you remember are all in there
somewhere.

Although this is no proof, it's an interesting mention of diary in this context, because Tom Riddle said pretty much the same about his diary:

I mean that this diary holds memories of terrible things. Things that
were covered up. Things that happened at Hogwarts School of Witchcraft
and Wizardry.

I'm certain that Tom Riddle needed the Diary to be a Pensieve as he wanted it read by someone else to carry on his "work" since Dumbledore no longer trusted him after Hagrid was expelled:

I knew it wouldn’t be safe to open the Chamber again while I was still
at school. But I wasn’t going to waste those long years I’d spent
searching for it. I decided to leave behind a diary, preserving my
sixteen-year-old self in its pages, so that one day, with luck, I
would be able to lead an­other in my footsteps, and finish Salazar
Slytherin’s noble work.

I believe, though I cannot recall if this was only my conjecture, the sentient memory of Tom Riddle came about because a combination of magics.

1st. The base magic was probably not too different from that of a magical portrait (not the even more basic moving photos, but the portraits that could interact with viewers). All interaction is through ink on the page rather than the spoken word. This would be quite a bit more secure than slips of paper or a more common muggle-type diary with a cheap lock. Tom could have used this to keep his own secret notes and records of his research without leaving incriminating evidence.

2nd. The journal became a Horcrux. Once a portion of Riddle's soul was invested in the Journal, it because much more powerful and capable of independent action. The fragment of the soul merged with the sentience of the journal to create a being capable of draining the life out of another to create Voldemort anew.