构造函数

属性

minClearSpace: number = ...

Minimum space to be cleared when the cache is full

缓存容量满时每次清理容量值

processInterval: number = 2000

The interval time for processing cache requests, in milliseconds

处理缓存请求的间隔时间,单位是毫秒

saveAccessTimeInterval: number = 15000

The interval time for saving file access time, in milliseconds. This time can be long, because it does not matter if the access time is not accurate.

保存文件访问时间的间隔时间,单位是毫秒。这个时间可以很长,因为访问时间就算不对问题也不大。

spaceLimit: number = ...

Maximum capacity of cache directory

缓存目录的最大容量

方法

  • 参数

    • url: string

      The URL of the file to be cached.

    • tempFilePath: string

      The temporary file path of the file to be cached.

    返回 void

    Add a file to the cache.

    将文件添加到缓存中。

  • 返回 void

    Clear all cache files. This method will not be executed immediately, but will be executed in the subsequent processing cycle.

    清除所有缓存文件。这个方法不会立即执行,而是在后续的处理周期中执行。

  • 参数

    • url: string

      The URL of the file to be retrieved.

    返回 Promise<string>

    The path of the cached file, or null if it is not in the cache.

    Get a file from the cache, if it is not in the cache, return null.

    从缓存中获取文件,如果不在缓存中,则返回null。