Flash Translation Layer
1.0
|
implementation of the lru cache More...
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include "include/log.h"
#include "include/lru.h"
Functions | |
struct lru_cache * | lru_init (const size_t capacity, lru_dealloc_fn deallocate) |
initialize the LRU cache data strcture More... | |
static struct lru_node * | lru_alloc_node (const uint64_t key, uintptr_t value) |
allocate the single node More... | |
static void | lru_dealloc_node (struct lru_node *node) |
deallcate the allocated node More... | |
static int | lru_delete_node (struct lru_node *head, struct lru_node *deleted) |
delete the node from the list More... | |
static int | __lru_do_evict (struct lru_cache *cache) |
implementation of the LRU eviction function More... | |
static int | lru_do_evict (struct lru_cache *cache, const uint64_t nr_evict) |
interfaces for execute the eviction process More... | |
static void | lru_node_insert (struct lru_node *node, struct lru_node *newnode) |
insert the lru node to the list More... | |
int | lru_put (struct lru_cache *cache, const uint64_t key, uintptr_t value) |
inser the key, value to the LRU cache More... | |
static struct lru_node * | lru_find_node (struct lru_cache *cache, const uint64_t key) |
find the node based on the key More... | |
uintptr_t | lru_get (struct lru_cache *cache, const uint64_t key) |
get data from the LRU cache More... | |
int | lru_free (struct lru_cache *cache) |
deallocate the LRU cache structure More... | |
implementation of the lru cache
|
static |
implementation of the LRU eviction function
cache | LRU cache data structure pointer |
|
static |
allocate the single node
key | key for identify the node |
value | value for data in the node |
|
static |
deallcate the allocated node
node | node which wants to deallocate |
delete the node from the list
head | list's head pointer |
deleted | target which wants to delete |
|
static |
interfaces for execute the eviction process
cache | LRU cache data structure pointer |
nr_evict | number of the entries to evict |
find the node based on the key
cache | LRU cache data structure pointer |
key | key which identifies the node |
int lru_free | ( | struct lru_cache * | cache | ) |
deallocate the LRU cache structure
cache | LRU cache data structure pointer |
uintptr_t lru_get | ( | struct lru_cache * | cache, |
const uint64_t | key | ||
) |
get data from the LRU cache
cache | LRU cache data structrue pointer |
key | key which identifies the node |
struct lru_cache* lru_init | ( | const size_t | capacity, |
lru_dealloc_fn | deallocate | ||
) |
initialize the LRU cache data strcture
capacity | number of the entries to insert the LRU |
deallocate | deallcation function for LRU's value |
insert the lru node to the list
node | pointer of the node, node->next will indicate the newnode |
newnode | newly allocated node to insert |
int lru_put | ( | struct lru_cache * | cache, |
const uint64_t | key, | ||
uintptr_t | value | ||
) |
inser the key, value to the LRU cache
cache | LRU cache data structure pointer |
key | key which identifies the node |
value | value which contains the data |