Loading...
Searching...
No Matches

Cache for ordered egress. More...

Detailed Description

Cache for ordered egress.

See also
Storage Backends for more information

clist based cache ordered by expiry time

Author
Simon Grund mail@.nosp@m.simo.nosp@m.ngrun.nosp@m.d.de

Definition in file cache.h.

#include "clist.h"
#include <stdint.h>
#include <stdbool.h>
#include "bplib.h"
#include "bplib_stor_vfs.h"
+ Include dependency graph for cache.h:

Go to the source code of this file.

Data Structures

struct  cache_list_node_t
 Bundle Cache element, containing information to uniquely identify a bundle on vfs. More...
 
struct  cache_list_t
 Bundle cache. More...
 
int bplib_cache_add (cache_list_t *cache, uint64_t node, uint64_t service, uint64_t expiry, uint8_t index)
 Add a bundle to the lookup cache.
 
int bplib_cache_get (cache_list_t *cache, char *bundle_path)
 Peek the given cache queue.
 
void bplib_cache_mark_front_consumed (cache_list_t *cache)
 Actually pop the front of the loadbuffer / cache.
 
bool bplib_cache_is_empty (cache_list_t *cache)
 Check if the cache is empty.
 

Function Documentation

◆ bplib_cache_add()

int bplib_cache_add ( cache_list_t * cache,
uint64_t node,
uint64_t service,
uint64_t expiry,
uint8_t index )

Add a bundle to the lookup cache.

It will not be added if the cache is full with more urgent bundles. If a bundle in the cache is less urgent, it will be replaced.

Parameters
cacheCache instance
nodeDestinatione node ID of the bundle
serviceDestinatione service ID of the bundle
expiryExpiry DTN time of the bundle
indexIndex in the storage, in case the above do not uniquely identify a bundle.
Return values
1if the new entry was NOT stored, since the cache is full with more urgent bundles
2if the new entry was stored and replaced another entry
0if the new entry was stored but without replacement

◆ bplib_cache_get()

int bplib_cache_get ( cache_list_t * cache,
char * bundle_path )

Peek the given cache queue.

Does not consume the front element, that has to be done with bplib_cache_mark_front_consumed()

Parameters
cachecache instance
bundle_pathbuffer for the string of the file path. Has to hold BPLIB_STOR_PATHLEN bytes.
Returns
0 If the cache is non empty and bundle_path has been updated

◆ bplib_cache_is_empty()

bool bplib_cache_is_empty ( cache_list_t * cache)

Check if the cache is empty.

Parameters
cacheCache instance

◆ bplib_cache_mark_front_consumed()

void bplib_cache_mark_front_consumed ( cache_list_t * cache)

Actually pop the front of the loadbuffer / cache.

Parameters
cacheCache instance