Crate rocket_file_cache [] [src]

Structs

Cache

The cache holds a number of files whose bytes fit into its size_limit. The cache acts as a proxy to the filesystem, returning cached files if they are in the cache, or reading a file directly from the filesystem if the file is not in the cache.

CacheBuilder

A builder for Caches.

CachedFile

A wrapper around an in-memory file. This struct is created when when a request to the cache is made. The CachedFile knows its path, so it can set the content type when it is serialized to a response.

Enums

CacheBuildError
ResponderFile

Wrapper around types that represent files and implement Responder<'static>.

Functions

access_priority_function

This priority function will value files in the cache based solely on the number of times the file is accessed.

default_priority_function

The default priority function used for determining if a file should be in the cache This function takes the square root of the size of the file times the number of times it has been accessed. This should give some priority to bigger files, while still allowing some smaller files to enter the cache.

normal_priority_function

Priority is calculated as size * access count.

small_files_access_priority_function

Favor small files. The smaller the file, the higher priority it will have. Does take into account the number of accesses the file has.

small_files_priority_function

Favor small files. The smaller the file, the higher priority it will have. Does not take into account the number of accesses the file has.

Type Definitions

PriorityFunction

Custom type of function that is used to determine how to add files to the cache. The first term will be assigned the access count of the file in question, while the second term will be assigned the size (in bytes) of the file in question. The result will represent the priority of the file to remain in or be added to the cache. The files with the largest priorities will be kept in the cache.