vitess.io/vitess@v0.16.2/go/cache/null.go (about)

     1  /*
     2  Copyright 2021 The Vitess Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package cache
    18  
    19  // nullCache is a no-op cache that does not store items
    20  type nullCache struct{}
    21  
    22  // Get never returns anything on the nullCache
    23  func (n *nullCache) Get(_ string) (any, bool) {
    24  	return nil, false
    25  }
    26  
    27  // Set is a no-op in the nullCache
    28  func (n *nullCache) Set(_ string, _ any) bool {
    29  	return false
    30  }
    31  
    32  // ForEach iterates the nullCache, which is always empty
    33  func (n *nullCache) ForEach(_ func(any) bool) {}
    34  
    35  // Delete is a no-op in the nullCache
    36  func (n *nullCache) Delete(_ string) {}
    37  
    38  // Clear is a no-op in the nullCache
    39  func (n *nullCache) Clear() {}
    40  
    41  // Wait is a no-op in the nullcache
    42  func (n *nullCache) Wait() {}
    43  
    44  func (n *nullCache) Len() int {
    45  	return 0
    46  }
    47  
    48  // Hits returns number of cache hits since creation
    49  func (n *nullCache) Hits() int64 {
    50  	return 0
    51  }
    52  
    53  // Hits returns number of cache misses since creation
    54  func (n *nullCache) Misses() int64 {
    55  	return 0
    56  }
    57  
    58  // Capacity returns the capacity of the nullCache, which is always 0
    59  func (n *nullCache) UsedCapacity() int64 {
    60  	return 0
    61  }
    62  
    63  // Capacity returns the capacity of the nullCache, which is always 0
    64  func (n *nullCache) MaxCapacity() int64 {
    65  	return 0
    66  }
    67  
    68  // SetCapacity sets the capacity of the null cache, which is a no-op
    69  func (n *nullCache) SetCapacity(_ int64) {}
    70  
    71  func (n *nullCache) Evictions() int64 {
    72  	return 0
    73  }