“Hard Time” is episode nineteen of season four of Star Trek: Deep Space Nine.
This episode opens with a man sitting inside a prison cell, drawing in the sand on the floor. He is then released, having served 20 years for espionage. The man is a much older Chief O’Brien, but it turns out he hasn’t really served 20 years.
He had been convicted and sentenced for espionage, but it was probably a mistake. However, the culture in question, instead of putting people into prisons, simply implants the memories of serving time. So Miles had served 20 years in just a few hours. The memories are completely real to him, so it has been the full 20 years, which causes problems, as he tries to adjust to his life again, Dr. Bashir being unable to remove the implanted memories.
Miles keeps saying that he spent the entire time alone, yet the various flashbacks of his imprisonment show that he had a cellmate. Obviously, he is hiding something.