A method, comprising the steps of: receiving via a data network a packet having a destination address, the destination address comprising a binary number having most significant bits; providing a main memory storing a routing table, wherein the routing table stored in the main memory comprises a longest prefix that is compatible with M of the most significant bits of the destination address, wherein M is a number; providing a cache memory, wherein a portion of the routing table stored in the main memory is also stored in cache entries in the cache memory, the cache entries each comprising a binary number having most significant bits, and information that specifies a number L, wherein the value of L is based on the length of the longest prefix stored in the main memory that is compatible with M of the most significant bits of the destination address; assigning the number M; in a first cache search, making a first determination that M of the most significant bits of at least one of the cache entries and M of the most significant bits of the destination address are identical and providing the information that specifies the number L, wherein the number L is a number of additional bits needed for a second cache search; in the second cache search, making a second determination that M+L of the most significant bits of one of the cache entries determined in the first cache search and M+L of the most significant bits of the destination address are identical; responsively to the second determination retrieving routing information from the cache memory; and processing the packet according to the routing information. receiving via a data network a packet having a destination address, the destination address comprising a binary number having most significant bits; providing a main memory storing a routing table, wherein the routing table stored in the main memory comprises a longest prefix that is compatible with M of the most significant bits of the destination address, wherein M is a number; providing a cache memory, wherein a portion of the routing table stored in the main memory is also stored in cache entries in the cache memory, the cache entries each comprising a binary number having most significant bits, and information that specifies a number L, wherein the value of L is based on the length of the longest prefix stored in the main memory that is compatible with M of the most significant bits of the destination address; assigning the number M; in a first cache search, making a first determination that M of the most significant bits of at least one of the cache entries and M of the most significant bits of the destination address are identical and providing the information that specifies the number L, wherein the number L is a number of additional bits needed for a second cache search; in the second cache search, making a second determination that M+L of the most significant bits of one of the cache entries determined in the first cache search and M+L of the most significant bits of the destination address are identical; responsively to the second determination retrieving routing information from the cache memory; and processing the packet according to the routing information.