CompilerCache
A unified implementation of ICompilerCache that stores compiled assemblies using an injected file system.
実装: ICompilerCache
コンストラクター
public CompilerCache(IFileSystem fileSystem, string path, TimeSpan timeout)
compilerCache = CompilerCache(fileSystem, path, timeout)
Initializes a new instance of the CompilerCache class with a specified timeout.
- fileSystem
- The file system to use for storing cached assemblies.
- path
- The path where cached assemblies will be stored.
- timeout
- Cache timeout.
プロパティ
public virtual int Count { get; }
value = compilerCache.Count
Gets the number of cached assemblies.
メソッド
public virtual void Add(string ext, IEnumerable<string> sources, IEnumerable<string> refs, byte[] assembly)
compilerCache.Add(ext, sources, refs, assembly)
Adds a compiled assembly to the cache.
- ext
- The file extension used in key generation.
- sources
- The source code files.
- refs
- The referenced assemblies.
- assembly
- The compiled assembly bytes to cache.
protected static string GetKey(string ext, IEnumerable<string> sources, IEnumerable<string> refs)
result = CompilerCache.GetKey(ext, sources, refs)
Generates a cache key based on the file extension, source code files, and referenced assemblies.
- ext
- The file extension used in key generation.
- sources
- The source code files.
- refs
- The referenced assemblies.
戻り値: The key.
protected DateTime GetTill()
result = compilerCache.GetTill()
Gets the expiration time for a cache entry.
戻り値: The expiration time for a cache entry.
public virtual ValueTask InitAsync(CancellationToken cancellationToken)
result = compilerCache.InitAsync(cancellationToken)
Initializes the cache.
- cancellationToken
- Cancellation token.
戻り値: A task representing the asynchronous operation.
protected bool Remove(string key)
result = compilerCache.Remove(key)
Removes a cached assembly based on the key.
- key
- The key.
戻り値: Operation result.
public virtual bool Remove(string ext, IEnumerable<string> sources, IEnumerable<string> refs)
result = compilerCache.Remove(ext, sources, refs)
Removes a cached assembly based on extension, sources, and references.
- ext
- The file extension used in key generation.
- sources
- The source code files.
- refs
- The referenced assemblies.
戻り値: true if the assembly was removed; otherwise, false.
protected void Set(string key, byte[] assembly)
compilerCache.Set(key, assembly)
Adds a compiled assembly to the in-memory cache.
- key
- The key.
- assembly
- Compiled assembly.
protected bool TryGet(string key, Byte[] assembly)
result = compilerCache.TryGet(key, assembly)
Tries to retrieve a cached assembly based on the key.
- key
- The key.
- assembly
- Compiled assembly.
戻り値: Operation result.
public virtual bool TryGet(string ext, IEnumerable<string> sources, IEnumerable<string> refs, Byte[] assembly)
result = compilerCache.TryGet(ext, sources, refs, assembly)
Tries to retrieve a cached assembly based on extension, sources, and references.
- ext
- The file extension used in key generation.
- sources
- The source code files.
- refs
- The referenced assemblies.
- assembly
- When this method returns, contains the cached assembly if found; otherwise, null.
戻り値: true if the assembly was retrieved from the cache; otherwise, false.