1. A method implemented by a network device, the method comprising: allocating, by the network device, a number of blocks of memory in a ternary content-addressable memory (TCAM) of the network device to each database of a plurality of databases; assigning, by the network device, unused blocks of memory of the TCAM to a free pool; detecting, by the network device, execution of a run mechanism by the TCAM; and allocating, by the network device and based on the execution of the run mechanism, one of the unused blocks of memory to a filter or rule of one of the plurality of databases.