aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-lru
diff options
context:
space:
mode:
authorYuchen Wu <[email protected]>2024-03-29 15:42:20 -0700
committerAndrew Hauck <[email protected]>2024-04-05 11:46:20 -0700
commitdfcd3d1d9f493b830e97757ba8d43c07ee81c030 (patch)
tree0cfa357cd4257b0ea2b7c2d116c937426190b1cd /pingora-lru
parent3c5d99c3f49a8d40a0fc16895b148dea9ea18e8d (diff)
downloadpingora-dfcd3d1d9f493b830e97757ba8d43c07ee81c030.tar.gz
pingora-dfcd3d1d9f493b830e97757ba8d43c07ee81c030.zip
Fix typos and grammar issues in docs
And other things. Co-authored-by: DimanNe <[email protected]> Co-authored-by: Xiaobo Liu <[email protected]> Co-authored-by: houseme <[email protected]> Co-authored-by: lilo <[email protected]> Co-authored-by: Yang He <[email protected]>
Diffstat (limited to 'pingora-lru')
-rw-r--r--pingora-lru/src/lib.rs4
-rw-r--r--pingora-lru/src/linked_list.rs10
2 files changed, 7 insertions, 7 deletions
diff --git a/pingora-lru/src/lib.rs b/pingora-lru/src/lib.rs
index a2ddf40..15a115b 100644
--- a/pingora-lru/src/lib.rs
+++ b/pingora-lru/src/lib.rs
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-//! An implementation of a LRU that focuses on memory efficiency, concurrency and persistence
+//! An implementation of an LRU that focuses on memory efficiency, concurrency and persistence
//!
//! Features
//! - keys can have different sizes
@@ -85,7 +85,7 @@ impl<T, const N: usize> Lru<T, N> {
/// Promote the key to the head of the LRU
///
- /// Return `true` if the key exist.
+ /// Return `true` if the key exists.
pub fn promote(&self, key: u64) -> bool {
self.units[get_shard(key, N)].write().access(key)
}
diff --git a/pingora-lru/src/linked_list.rs b/pingora-lru/src/linked_list.rs
index 7a29010..1f7a229 100644
--- a/pingora-lru/src/linked_list.rs
+++ b/pingora-lru/src/linked_list.rs
@@ -18,7 +18,7 @@
//!
//! Features
//! - Preallocate consecutive memory, no memory fragmentation.
-//! - No shrink function: for Lru cache that grows to a certain size but never shrink.
+//! - No shrink function: for Lru cache that grows to a certain size but never shrinks.
//! - Relatively fast and efficient.
// inspired by clru::FixedSizeList (Élie!)
@@ -72,10 +72,10 @@ impl Nodes {
next: NULL,
data,
};
- // Constrain the growth of vec: vec always double its capacity when it needs to grow
+ // Constrain the growth of vec: vec always double its capacity when it needs to grow.
// It could waste too much memory when it is already very large.
// Here we limit the memory waste to 10% once it grows beyond the cap.
- // The amortized growth cost is O(n) beyond the max of the initial reserved capacity and
+ // The amortized growth cost is O(n) beyond the max of the initially reserved capacity and
// the cap. But this list is for limited sized LRU and we recycle released node, so
// hopefully insertions are rare beyond certain sizes
if self.data_nodes.capacity() > VEC_EXP_GROWTH_CAP
@@ -129,7 +129,7 @@ pub struct LinkedList {
free: Vec<Index>, // to keep track of freed node to be used again
}
// Panic when index used as parameters are invalid
-// Index returned by push_* are always valid.
+// Index returned by push_* is always valid.
impl LinkedList {
/// Create a [LinkedList] with the given predicted capacity.
pub fn with_capacity(capacity: usize) -> Self {
@@ -178,7 +178,7 @@ impl LinkedList {
self.node(index).map(|n| n.data)
}
- // safe because index still needs to be in the range of the vec
+ // safe because the index still needs to be in the range of the vec
fn peek_unchecked(&self, index: Index) -> &u64 {
&self.nodes[index].data
}