type Cache … type cacheTable … type cacheEntry … func registerCache(unsafe.Pointer) // Register registers the cache with the runtime, // so that c.ptable can be cleared at the start of each GC. // Register must be called during package initialization. func (c *Cache[K, V]) Register() { … } const cacheSize … // table returns a pointer to the current cache hash table, // coping with the possibility of the GC clearing it out from under us. func (c *Cache[K, V]) table() *cacheTable[K, V] { … } // Clear clears the cache. // The runtime does this automatically at each garbage collection; // this method is exposed only for testing. func (c *Cache[K, V]) Clear() { … } // Get returns the cached value associated with v, // which is either the value v corresponding to the most recent call to Put(k, v) // or nil if that cache entry has been dropped. func (c *Cache[K, V]) Get(k *K) *V { … } // Put sets the cached value associated with k to v. func (c *Cache[K, V]) Put(k *K, v *V) { … }