Memory, as we know it, is the ability to retain knowledge. Memory does not simply exist on its own. Instead, cognitive psychologists see memory as part of a continuum of information processing that begins with attention, sensation, perception, and learning. Memory can be divided into three steps: encoding, storage, and retrieval. Just like computers, encoding of incoming information must occur before the information can be processed further.
Encoding is the process of acquiring information and transferring it into memory. Both computer and brain must store incoming data. In both systems, storage can vary in time from very brief traces to practically permanent storage. Computers store encoded information in very reliable and secure way, future retrieval would get identical information from what was stored. However for humans, bits of information are stored and later reconstructed into usable memories. This process may create useful memories but also entail errors and distortions in the stored memory. The culmination of the memory process for both brain and computer is the retrieval of stored information. Two of the most common causes of retrieval failure are interference and stress.
So how does memory work? There are a few main types of memory: sensory memory, short-term memory/working memory and long-term memory.
Sensory memory is the shortest-term type of memory. It involves stimuli received through the five senses of sight, smell, hearing, touch and taste. It is being able to retain sensory information after the original stimuli ends for a brief amount of time. For example, seeing a butterfly fly past and remembering what it looks like with just a glimpse. Sensory input is translated, or transduced, into several types of code or representation. A representation of a memory refers to a mental model of information that exists even when the information is no longer available.
Short-term memory is the second shortest-term type of memory. It can be thought of being able to retain and process information at the same time. Only holding a small amount of information, it can last from 15 to 30 seconds at most. An example would be retaining information for a short time in order to complete a task, like listening to someone read out a problem and thinking of a solution while the person finishes reading it. However, this stored information would disappear quickly unless we make a conscious effort to retain it. As for working memory, it is more complex, allowing multiple processes to occur simultaneously, whereas short-term memory allows managing a single process at a time.
Long-term memory is the longest-term type of memory, and the final stage of memory processing. Unlike sensory, short-term, and working memory, long-term memory seems to have barely any limitations in either capacity or duration. We do not appear to run out of room in long-term memory for new data, and information can last a lifetime. How is long-term memory kept after so much time passing? In most cases, information moves from short-term or working memory to long-term memory through rehearsal. Rehearsal can be divided into maintenance rehearsal; simple repetition of the material, and elaborative rehearsal; linking the new material to things you already know.
The above is a diagram of how memory processing is like through an illustration.