code: func (c *dbCache) Snapshot() (*dbCacheSnapshot, error) {
  	dbSnapshot, err := c.ldb.GetSnapshot()
  	if err != nil {
  		str := "failed to open transaction"
  		return nil, convertErr(str, err)
  	}
  
  	// Since the cached keys to be added and removed use an immutable treap,
  	// a snapshot is simply obtaining the root of the tree under the lock
  	// which is used to atomically swap the root.
  	c.cacheLock.RLock()
  	cacheSnapshot := &dbCacheSnapshot{
  		dbSnapshot:    dbSnapshot,
  		pendingKeys:   c.cachedKeys,
  		pendingRemove: c.cachedRemove,
  	}
  	c.cacheLock.RUnlock()
  	return cacheSnapshot, nil
  }
docs: // Snapshot returns a snapshot of the database cache and underlying database at
  // a particular point in time.
  //
  // The snapshot must be released after use by calling Release.