Refrigerators and heat pumps are very similar to heat engines. They consist of a heat source, a heat sink, and a cycle between the two.
A refrigerant enters a compressor as vapor, where it is (wow) compressed. It leaves the compressor at high pressure and temperature, and as it flows through a condensor, loses some of its heat to the outside (as waste in the case of a fridge, as heat to warm a house in the case of a heat pump) and begins to condense into liquid. The fluid then passes through a throttling valve, where the pressure and temperature drop dramatically. Finally, the low-temperature refrigerant enters an evaporator, where it evaporates by absorbing heat from the space to be refrigerated - in the case of a refrigerator, the fridge, or for a heat pump, the outdoors. The heated vapor proceeds to the compressor, and the cycle begins again.
The efficiency of a refrigerator or a heat pump is known as the coefficient of performance (COP). In the case of a refrigerator, it is the ratio of the desired heat loss to the required work input; for a heat pump, it is the ratio of the desired heat output to the required work input.
COP = Heat(desired)/Work(in)
Conservation of energy also holds for refrigerators and heat pumps, i.e.,
Heat(out) = Heat(in) + Work(net, in)