Implementing pattern cache with a maximum size of entries.