github.com/blend/go-sdk@v1.20220411.3/cache/cache.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package cache
     9  
    10  import "sync"
    11  
    12  // Cache is a type that implements the cache interface.
    13  type Cache interface {
    14  	Has(key interface{}) bool
    15  	GetOrSet(key interface{}, valueProvider func() (interface{}, error), options ...ValueOption) (interface{}, bool, error)
    16  	Set(key, value interface{}, options ...ValueOption)
    17  	Get(key interface{}) (interface{}, bool)
    18  	Remove(key interface{}) (interface{}, bool)
    19  }
    20  
    21  // Locker is a cache type that supports external control of locking for both exclusive and reader/writer locks.
    22  type Locker interface {
    23  	sync.Locker
    24  	RLock()
    25  	RUnlock()
    26  }