mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
page_cache: split unlink() out of detach()
The unlink function removes an entry from the LRU. The detach function removes an entry in the cache and clears page contents.
This commit is contained in:
parent
6763aa0cd5
commit
c8beddab09
1 changed files with 4 additions and 2 deletions
|
@ -109,7 +109,7 @@ impl DumbLruPageCache {
|
|||
let mut ptr = self.get_ptr(key)?;
|
||||
let page = unsafe { ptr.as_mut().page.clone() };
|
||||
if touch {
|
||||
self.detach(ptr, false);
|
||||
self.unlink(ptr);
|
||||
self.touch(ptr);
|
||||
}
|
||||
Some(page)
|
||||
|
@ -128,7 +128,10 @@ impl DumbLruPageCache {
|
|||
debug!("cleaning up page {}", page.get().id);
|
||||
let _ = page.get().contents.take();
|
||||
}
|
||||
self.unlink(entry);
|
||||
}
|
||||
|
||||
fn unlink(&mut self, mut entry: NonNull<PageCacheEntry>) {
|
||||
let (next, prev) = unsafe {
|
||||
let c = entry.as_mut();
|
||||
let next = c.next;
|
||||
|
@ -138,7 +141,6 @@ impl DumbLruPageCache {
|
|||
(next, prev)
|
||||
};
|
||||
|
||||
// detach
|
||||
match (prev, next) {
|
||||
(None, None) => {
|
||||
self.head.replace(None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue