Struct rocket_file_cache::Cache [] [src]

pub struct Cache { /* fields omitted */ }

The Cache holds a set number of files. The Cache acts as a proxy to the filesystem. When a request for a file is made, the Cache checks to see if it has a copy of the file. If it does have a copy, it returns the copy. If it doesn't have a copy, it reads the file from the FS and tries to cache it. If there is room in the Cache, the cache will store the file, otherwise it will increment a count indicating the number of access attempts for the file. If the number of access attempts for the file are higher than the least in demand file in the Cache, the cache will replace the low demand file with the high demand file.

Methods

impl Cache
[src]

[src]

Creates a new Cache with the given size limit. Currently the size_limit is representative of the number of files stored in the Cache, but plans exist to make size limit represent the maximum number of bytes the Cache's file_map can hold.

[src]

Attempt to store a given file in the the cache. Storing will fail if the current files have more access attempts than the file being added. If the provided file has more more access attempts than one of the files in the cache, but the cache is full, a file will have to be removed from the cache to make room for the new file.

[src]

Increments the access count. Gets the file from the cache if it exists.

[src]

Either gets the file from the cache, gets it from the filesystem and tries to cache it, or fails to find the file and returns None.

DEFAULT_PRIORITY_FUNCTION: PriorityFunction = <Cache>::balanced_priority

ACCESS_PRIORITY_FUNCTION: PriorityFunction = <Cache>::access_priority

Trait Implementations

impl Debug for Cache
[src]

[src]

Formats the value using the given formatter.