In the process of stripping, I removed most of the backingstoreimplementations, except all of the instrumentation <used for logs and counters>, except that the configuration file must be used.
The current function can only rely on memory for caching. Modifying constants affects cache behavior.
However, without relying on the configuration file, you can easily integrate your own framework.
Because there was no time to test the migration yesterday Code , So no code is released
Currently, only the absoultetime slidingtime neverexpire method is supported. For filedependency, You need to integrate an action by yourself. Therefore, you have not performed any tests and have not studied whether the transplanted code is feasible.
Http://files.cnblogs.com/wildfish/Caching.rar
I tested it today and thought it was okay.
By the way, the test code is released. Using System;
Using System. Data;
Using Nunit. Framework;
Using Fishsky. systemframework. caching;
Using Fishsky. systemframework. caching. expirations;
Using Fishsky. systemframework. base;
Using Fishsky. Data. base;
Using System. Threading;
Namespace Fishskytest. systemframeworktest
{
/**/ /// <Summary>
///A summary of cachingtesting.
/// </Summary>
[Testfixture]
Public Class Cachingtesting
{
Private Cachemanager Manager = Cachefactory. getcachemanager ();
Private Static String Keywordtostore1 = " Keywordtostore1 " ;
Private Static String Keywordtostore2 = " Keywordtostore2 " ;
Private Static String Keywordtostore3 = " Keywordtostore3 " ;
Private Static String Keywordtostore4 = " Keywordtostore4 " ;
Public Cachingtesting ()
{
}
Setup # Region Setup
[Setup]
Public Void Setup ()
{
Manager. Flush ();
}
# Endregion
Testtimespancacheaddremove # Region Testtimespancacheaddremove
[Test]
Public Void Testtimespancacheaddremove ()
{
Console. writeline ( " Testing start. " );
Wherefield Wf = New Wherefield ( " Penavicoxm " , Typeof ( String ), 20 , True , False );
WF. fieldvalue = " Kevin " ;
Setfield SF = New Setfield ( " Penavicoxmset " , Typeof ( String ), 30 , False );
SF. fieldvalue = " Kevin. Chin " ;
Timespan timespan1 = New Timespan ( 0 , 10 , 0 );
Timespan timespan2 = New Timespan ( 0 , 0 , 20 );
Slidingtime expiretime1 = New Slidingtime (timespan1 );
Slidingtime expiretime2 = New Slidingtime (timespan2 );
Manager. Add (cachingtesting. keywordtostore1, WF, cacheitempriority. Normal, Null , Expiretime1 );
Manager. Add (cachingtesting. keywordtostore2, SF, cacheitempriority. Normal, Null , Expiretime2 );
Wherefield cachedwf = Manager. getdata (cachingtesting. keywordtostore1) As Wherefield;
Assert. isnotnull (cachedwf );
Assert. areequal (cachedwf. fieldvalue. tostring (), " Kevin " );
Manager. Remove (cachingtesting. keywordtostore1 );
Object OBJ = Manager. getdata (cachingtesting. keywordtostore1 );
Assert. isnull (OBJ );
Console. writeline ( " Testing will sleep 180 seconds. " );
Thread. Sleep ( 180000 );
Object Nullcache2 = Manager. getdata (cachingtesting. keywordtostore2 );
Assert. isnull (nullcache2 );
Console. writeline ( " Testing finished! " );
}
# Endregion
Testabsolutetime # Region Testabsolutetime
[Test]
Public Void Testabsolutetime ()
{
Setfield sf2 = New Setfield ( " Penavicoxmset " , Typeof ( String ), 30 , False );
Sf2.fieldvalue = " Kevin. Chin " ;
// Each time u wanna test, must change the time to one minute before the test
Datetime refreshdatetime = New Datetime ( 2006 , 1 , 12 , 10 , 41 , 20 );
Absolutetime expiretime3 = New Absolutetime (refreshdatetime );
Manager. Add (cachingtesting. keywordtostore3, sf2, cacheitempriority. Normal, Null , Expiretime3 );
Assert. isnotnull (Manager. getdata (cachingtesting. keywordtostore3 ));
Thread. Sleep ( 120000 );
Assert. isnull (Manager. getdata (cachingtesting. keywordtostore3 ));
}
# Endregion
Testneverexpired # Region Testneverexpired
[Test]
Public Void Testneverexpired ()
{
Setfield sf2 = New Setfield ( " Penavicoxmset " , Typeof ( String ), 30 , False );
Sf2.fieldvalue = " Kevin. Chin " ;
Manager. Add (cachingtesting. keywordtostore4, sf2, cacheitempriority. Normal, Null , Null );
Assert. isnotnull (Manager. getdata (cachingtesting. keywordtostore4 ));
Thread. Sleep ( 120000 );
Assert. isnotnull (Manager. getdata (cachingtesting. keywordtostore4 ));
}
# Endregion
}
}