Is there any way to count the number of items in cache?
Given the interface provided for cache backends (CacheBackendInterface), you cannot.  

It doesn't expose a method that returns the number of items in the case, which would have made things easier for your use case. There could be a cache backend with a method to count the number of items in the cache, but since it is not part of CacheBackendInterface, that would not be a method you find in every cache backend.
Since CacheBackendInterface doesn't expose any method to know the database table used for cache bins, you should assume some implementation details, and that those details are never changed. If you make assumptions about those implementation details, you can use a SQL query to count the number of items contained in a cache bin. Keep in mind that a cache backend could not use a database table at all, such as in the case of the ApcuBackend class.