I fail to see how such ability would evolve in a biological organism as we know it. I will first make very crude analogy between computers and organisms to argue that simply storing that information would be very difficult. Consider that one is to store the level of happiness of the organism itself every second. This would mean storing a bit of information (1/0, happy/sad) every second for the duration of the life of the organism. During one year, and in computer terms, this would equal to roughly 3.8 Mb. Over a human life this would be roughly 300Mb. Using DNA, as suggested before me, this would take approximately 5 human DNA molecules to store. To recall an event perfectly, you would need to store much much more information.
Storing all this information in DNA would however, not be possible. Firstly, growing DNA molecule (as we know it) would make copying and reading it increasingly slower. This would mean that towards the end of the life of the organism its cell division (as we know it) would slow down. This would also slow down all aspects of life of the organism. (Side note, this would of course open various interesting plot options with old individuals turning into "oracles" that are only able to lie down being fed and treated by others but do know every single thing they have ever seen/read/heard). This slowdown would also affect the process of recalling these memories in the first place. In addition, storing memories in the DNA would require the infomation be added to the molecule simultaneously everywhere in the body.
Storing this information in the "brain" of the organism would also be problematic. The structure of the brain would have to be completely different, more computer like, than our brain. Notice, that we do not necessarily learn to remember every single detail but rather associate things and memories. This is also the fundamental way our brain works. But note also, that storing an indefinite amount of data would require indefinitely large brain. Our brain, for example, consists of finitely many synapses. Such network is only able to represent a finitely complex set of information.
After the technical difficulties we come to my next point, evolving such ability. Clearly, if we consider evolution as we know it there would need to be evolutionary pressure for the nature to prefer such trait. Something in the environment of the organisms allows individuals with a very good and accurate memory to live longer or to have more/healthier offspring. Possibly, finding food, shelter or mating locations are few and far between and difficult to find. Remembering, for example, the how to find these locations could be useful enough to cause evolutionary pressure.
Such memory has a lot to do with the intelligence of the creature. The way you describe the ability suggests that the organism is able to comprehend this information (recall memories and act upon them). The organism has to be also smart enough to filter all these stored memories from each other and choose the most relevant (from possibly a massive set) to base its decisions on. Consequently, from the evolution point of view, the organism would have to evolve simultaneously smarter and better in remembering. At some point in during the evolutionary process the organism is completely capable to manage with less than perfect memory.
If we compare this to us homo sapiens, we see that currently we are rather smart but have not perfect but very well functioning memory. But by being smart enough we have essentially taken the initiative from nature and there is hardly any evolutionary pressure left on us. If your organism would reach similar situation, the evolutionary steps to create ever better memory would be removed. Essentially, if you want to evolve such organism having better memory has to be increasingly important. Usually in real world, however, adding complexity brings in a phenomenon called diminishing returns. In this context, as the brains of the organism allows more and more information to be stored, adding "memory locations" becomes more and more costly (in regards of energy consumption, volume!, and the length of the evolutionary process).