A method is provided for compressing data from a stream of values using one or many distinct memory addresses as workspace, each memo address containing one or many values. The method works by reading two contiguous data values, of length K and N bits, from the stream, as a memory address reference (MAR) and a symbol, respectively. If the symbol does not match any of the values in the memory address pointed by MAR, the symbol replaces one of those values, and a MISS code, followed by the symbol, is appended to the compressed stream. Otherwise, a HIT code is added appended directly to the compressed stream, the code representing the location, of the matched value in the memory address. Advantageously, the workspace behaves analogous to a cache memory used in computer architecture, allowing it to be implemented using content addressable memory or associative arrays in hardware or software implementations, respectively.