From: Michael D. <mik...@us...> - 2004-10-29 05:55:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16772/NHibernate/Cache Modified Files: HashtableCache.cs ICache.cs NonstrictReadWriteCache.cs ReadOnlyCache.cs ReadWriteCache.cs Added Files: CacheFactory.cs Log Message: NH-90 : code for a pluggable cache. Index: NonstrictReadWriteCache.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/NonstrictReadWriteCache.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NonstrictReadWriteCache.cs 26 Oct 2004 21:15:09 -0000 1.2 --- NonstrictReadWriteCache.cs 29 Oct 2004 05:55:26 -0000 1.3 *************** *** 13,19 **** private ICache _cache; ! public NonstrictReadWriteCache(ICache cache) { - _cache = cache; } --- 13,18 ---- private ICache _cache; ! public NonstrictReadWriteCache() { } Index: ReadWriteCache.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/ReadWriteCache.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReadWriteCache.cs 26 Oct 2004 21:15:09 -0000 1.4 --- ReadWriteCache.cs 29 Oct 2004 05:55:26 -0000 1.5 *************** *** 17,23 **** private ICache _cache; ! public ReadWriteCache(ICache cache) { - _cache = cache; } --- 17,22 ---- private ICache _cache; ! public ReadWriteCache() { } Index: HashtableCache.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/HashtableCache.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HashtableCache.cs 26 Oct 2004 21:15:07 -0000 1.3 --- HashtableCache.cs 29 Oct 2004 05:55:26 -0000 1.4 *************** *** 3,8 **** using System.Runtime.CompilerServices; ! namespace NHibernate.Cache { ! /// <summary> /// A simple <c>Hashtable</c> based cache --- 3,8 ---- using System.Runtime.CompilerServices; ! namespace NHibernate.Cache ! { /// <summary> /// A simple <c>Hashtable</c> based cache *************** *** 54,71 **** } - // were added in h2.1 - // public void Lock( object key ) - // { - // } - // - // public void Unlock( object key ) - // { - // } - // - // public long NextTimestamp() - // { - // return Timestamper.Next(); - // } - #endregion } --- 54,57 ---- Index: ReadOnlyCache.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/ReadOnlyCache.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ReadOnlyCache.cs 26 Oct 2004 21:15:09 -0000 1.5 --- ReadOnlyCache.cs 29 Oct 2004 05:55:26 -0000 1.6 *************** *** 14,20 **** private ICache _cache; ! public ReadOnlyCache(ICache cache) { - _cache = cache; } --- 14,19 ---- private ICache _cache; ! public ReadOnlyCache() { } Index: ICache.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cache/ICache.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ICache.cs 26 Oct 2004 21:15:09 -0000 1.4 --- ICache.cs 29 Oct 2004 05:55:26 -0000 1.5 *************** *** 51,61 **** string Region {set;} - // were added in h2.1 - // void Lock( object key ); - // - // void Unlock( object key ); - // - // long NextTimestamp(); - } --- 51,54 ---- --- NEW FILE: CacheFactory.cs --- using System; using System.Xml; namespace NHibernate.Cache { /// <summary> /// Summary description for CacheFactory. /// </summary> public class CacheFactory { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(CacheFactory) ); private CacheFactory() { // not publically creatable } public const string ReadOnly = "read-only"; public const string ReadWrite = "read-write"; public const string NonstrictReadWrite = "nonstrict-read-write"; public const string Transactional = "transactional"; public static ICacheConcurrencyStrategy CreateCache(XmlNode node, string name, bool mutable) { return CacheFactory.CreateCache( node.Attributes["usage"].Value, name, mutable ); } // was private in h2.1 public static ICacheConcurrencyStrategy CreateCache(string usage, string name, bool mutable) { if( log.IsDebugEnabled ) { log.Debug( "cache for: " + name + "usage strategy: " + usage ); } ICacheConcurrencyStrategy ccs = null; switch( usage ) { case CacheFactory.ReadOnly : if( mutable ) { log.Warn( "read-only cache configured for mutable: " + name ); } ccs = new ReadOnlyCache(); break; case CacheFactory.ReadWrite : ccs = new ReadWriteCache(); break; case CacheFactory.NonstrictReadWrite : ccs = new NonstrictReadWriteCache(); break; case CacheFactory.Transactional : // TODO: build this //ccs = new TransactionalCache(); break; default : throw new MappingException( "cache usage attribute should be read-write, read-only, nonstrict-read-write, or transactional" ); } return ccs; } } } |