Interface IPolicy<T>
Namespace: FreeSql.Internal.ObjectPool
Assembly: FreeSql.dll
Syntax
public interface IPolicy<T>
Type Parameters
| Name | Description |
|---|---|
| T |
Properties
| Improve this Doc View SourceAsyncGetCapacity
异步获取排队队列大小,小于等于0不生效
Declaration
int AsyncGetCapacity { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
CheckAvailableInterval
后台定时检查可用性间隔秒数
Declaration
int CheckAvailableInterval { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IdleTimeout
空闲时间,获取时若超出,则重新创建
Declaration
TimeSpan IdleTimeout { get; set; }
Property Value
| Type | Description |
|---|---|
| System.TimeSpan |
IsAutoDisposeWithSystem
监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放
Declaration
bool IsAutoDisposeWithSystem { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsThrowGetTimeoutException
获取超时后,是否抛出异常
Declaration
bool IsThrowGetTimeoutException { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Name
名称
Declaration
string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
PoolSize
池容量
Declaration
int PoolSize { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
SyncGetTimeout
默认获取超时设置
Declaration
TimeSpan SyncGetTimeout { get; set; }
Property Value
| Type | Description |
|---|---|
| System.TimeSpan |
Weight
权重
Declaration
int Weight { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Methods
| Improve this Doc View SourceOnAvailable()
事件:可用时触发
Declaration
void OnAvailable()
OnCheckAvailable(Object<T>)
检查可用性
Declaration
bool OnCheckAvailable(Object<T> obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object<T> | obj | 资源对象 |
Returns
| Type | Description |
|---|---|
| System.Boolean |
OnCreate()
对象池的对象被创建时
Declaration
T OnCreate()
Returns
| Type | Description |
|---|---|
| T | 返回被创建的对象 |
OnDestroy(T)
销毁对象
Declaration
void OnDestroy(T obj)
Parameters
| Type | Name | Description |
|---|---|---|
| T | obj | 资源对象 |
OnGet(Object<T>)
从对象池获取对象成功的时候触发,通过该方法统计或初始化对象
Declaration
void OnGet(Object<T> obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object<T> | obj | 资源对象 |
OnGetAsync(Object<T>)
从对象池获取对象成功的时候触发,通过该方法统计或初始化对象
Declaration
Task OnGetAsync(Object<T> obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object<T> | obj | 资源对象 |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
OnGetTimeout()
从对象池获取对象超时的时候触发,通过该方法统计
Declaration
void OnGetTimeout()
OnReturn(Object<T>)
归还对象给对象池的时候触发
Declaration
void OnReturn(Object<T> obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object<T> | obj | 资源对象 |
OnUnavailable()
事件:不可用时触发
Declaration
void OnUnavailable()