C# Class Ivony.Caching.DiskCacheManager

磁盘缓存管理器,磁盘缓存管理器负责打开调度文件打开和关闭,过期缓存清理等
Inheritance: IDisposable
Exibir arquivo Open project: Ivony/Ivony.Caching Class Usage Examples

Public Methods

Method Description
DiskCacheManager ( string rootPath, bool persistMode = true ) : System

创建磁盘缓存管理器对象

Dispose ( ) : void

释放所有资源,删除文件夹

GetCachePolicy ( string cacheKey ) : CachePolicyItem

获取缓存策略对象

ReadStream ( string cacheKey ) : Task

读取一个流

Remove ( string cacheKey ) : void
SetCachePolicy ( string cacheKey, CachePolicyItem cachePolicy ) : void

设置缓存策略对象

ValidateCacheKey ( string cacheKey ) : string
WriteStream ( string cacheKey, MemoryStream data ) : Task
WriteStream ( string cacheKey, byte data ) : Task

Private Methods

Method Description
AssignCacheDirectory ( ) : void

分配一个新的缓存目录(一般用于清除缓存)

Initialize ( ) : void
ReadStream ( FileStream stream ) : Task
WriteStream ( FileStream stream, MemoryStream data ) : Task

将数据写入文件流

Method Details

DiskCacheManager() public method

创建磁盘缓存管理器对象
public DiskCacheManager ( string rootPath, bool persistMode = true ) : System
rootPath string 缓存文件存放的路径
persistMode bool 持久模式,在此模式下,重启后将尽可能的使用原来的缓存目录
return System

Dispose() public method

释放所有资源,删除文件夹
public Dispose ( ) : void
return void

GetCachePolicy() public method

获取缓存策略对象
public GetCachePolicy ( string cacheKey ) : CachePolicyItem
cacheKey string 缓存键
return CachePolicyItem

ReadStream() public method

读取一个流
public ReadStream ( string cacheKey ) : Task
cacheKey string 缓存键
return Task

Remove() public method

public Remove ( string cacheKey ) : void
cacheKey string
return void

SetCachePolicy() public method

设置缓存策略对象
public SetCachePolicy ( string cacheKey, CachePolicyItem cachePolicy ) : void
cacheKey string
cachePolicy CachePolicyItem
return void

ValidateCacheKey() public method

public ValidateCacheKey ( string cacheKey ) : string
cacheKey string
return string

WriteStream() public method

public WriteStream ( string cacheKey, MemoryStream data ) : Task
cacheKey string
data System.IO.MemoryStream
return Task

WriteStream() public method

public WriteStream ( string cacheKey, byte data ) : Task
cacheKey string
data byte
return Task