CompilerCache

Ecng.Compilation

A unified implementation of ICompilerCache that stores compiled assemblies using an injected file system.

Implementiert: ICompilerCache

Konstruktoren

CompilerCache
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.

Eigenschaften

Count
public virtual int Count { get; }
value = compilerCache.Count

Gets the number of cached assemblies.

Timeout
public TimeSpan Timeout { get; }
value = compilerCache.Timeout

Gets the cache timeout.

Methoden

Add
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.
Clear
public virtual void Clear()
compilerCache.Clear()

Clears all cached assemblies.

GetKey
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.

Rückgabe: The key.

GetTill
protected DateTime GetTill()
result = compilerCache.GetTill()

Gets the expiration time for a cache entry.

Rückgabe: The expiration time for a cache entry.

InitAsync
public virtual ValueTask InitAsync(CancellationToken cancellationToken)
result = compilerCache.InitAsync(cancellationToken)

Initializes the cache.

cancellationToken
Cancellation token.

Rückgabe: A task representing the asynchronous operation.

Remove
protected bool Remove(string key)
result = compilerCache.Remove(key)

Removes a cached assembly based on the key.

key
The key.

Rückgabe: Operation result.

Remove
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.

Rückgabe: true if the assembly was removed; otherwise, false.

Set
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.
TryGet
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.

Rückgabe: Operation result.

TryGet
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.

Rückgabe: true if the assembly was retrieved from the cache; otherwise, false.