code: func New(cfg Config) (*Memory, error) {
  	if err := cfg.CheckAndSetDefaults(); err != nil {
  		return nil, trace.Wrap(err)
  	}
  	ctx, cancel := context.WithCancel(cfg.Context)
  	buf, err := backend.NewCircularBuffer(ctx, cfg.BufferSize)
  	if err != nil {
  		cancel()
  		return nil, trace.Wrap(err)
  	}
  	m := &Memory{
  		Mutex: &sync.Mutex{},
  		Entry: log.WithFields(log.Fields{
  			trace.Component: teleport.ComponentMemory,
  		}),
  		Config: cfg,
  		tree:   btree.New(cfg.BTreeDegree),
  		heap:   newMinHeap(),
  		cancel: cancel,
  		ctx:    ctx,
  		buf:    buf,
  	}
  	return m, nil
  }
docs: // New creates a new memory backend