Created
April 26, 2020 11:47
-
-
Save arpitbbhayani/b7aa662eb51e16036c312a9cb1a9a812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_page(page_id:int) -> Page: | |
# Check if the page is available in the cache | |
page = cache.get_page(page_id) | |
# if the page is retrieved from the main memory | |
# return the page. | |
if page: | |
return page | |
# retrieve the page from the disk | |
page = disk.get_page(page_id) | |
# put the page in the cache, | |
# if the cache is full, evict a page which is | |
# least recently used. | |
if cache.is_full(): | |
cache.evict_page() | |
# put the page in the cache | |
cache.put_page(page) | |
# return the pages | |
return page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment