There is a signature cache in Bitcoin, which is used to cache the result of signature verification to avoid extra signature verification. What data is stored in the signature cache? Is it stored in the form of key-value pairs or other forms? When a Bitcoin node performs block validation, how does it determine that the signature verification result of a transaction is already in the signature cache?
The signature cache is basically a set of public key, message hash, and signature tuples. When there is a valid pubkey, message hash, and signature combination, all of those are hashed together with SHA256. This hash is then inserted into the signature cache. So the signature cache contains only the hashes of valid combinations. When verifying a signature, the pubkey, message hash, and signature are hashed together, and that resulting hash is looked up in the signature cache. If it is in there, then the signature is known to be valid and actual signature verification can be skipped.
The signature cache itself is not just a set. It is actually a Cuckoo cache which is a type of hash table that guarantees constant time lookup in the worst case.