1. A method implemented by a network device, the method comprising: allocating, by the network device, a particular number of memory blocks in a ternary content-addressable memory (TCAM) of the network device to each database of a plurality of databases of the TCAM; creating, by the network device, a list of additional memory blocks in an external TCAM of the network device; providing, by a particular database of the plurality of databases of the TCAM and to the external TCAM, an indication that the particular database of the TCAM is full; receiving, by the external TCAM, a request to store one or more rules in the particular database of the TCAM; and allocating, by the external TCAM, an additional memory block, from the list of additional memory blocks, to store the one or more rules based on the indication and the request.