diff --git a/MySqlPlus/DateTimeToUnixConverter.cs b/MySqlPlus/DateTimeToUnixConverter.cs
index a515ca1..d8e0c67 100644
--- a/MySqlPlus/DateTimeToUnixConverter.cs
+++ b/MySqlPlus/DateTimeToUnixConverter.cs
@@ -14,7 +14,7 @@ namespace MontoyaTech.MySqlPlus
///
/// Returns the MySql Type this converter converts to.
///
- public string ConvertToType { get { return "BIGINT UNSIGNED"; } }
+ public string ConvertToType => "BIGINT UNSIGNED";
///
/// Converts from a Unix Time to a DateTime.
diff --git a/MySqlPlus/GlobalTimeStamp.cs b/MySqlPlus/GlobalTimeStamp.cs
index 648cd8f..8b393e4 100644
--- a/MySqlPlus/GlobalTimeStamp.cs
+++ b/MySqlPlus/GlobalTimeStamp.cs
@@ -9,9 +9,7 @@ using System.Threading.Tasks;
namespace MontoyaTech.MySqlPlus
{
///
- /// This timestamp runs on its own and it
- /// uses very little CPU usage to keep track of time. This is a very
- /// useful system. This timestamp is in elapsed miliseconds.
+ /// An efficient elapsed miliseconds timestamp that can be used to keep track of time.
///
internal class GlobalTimeStamp : IDisposable
{
@@ -117,6 +115,7 @@ namespace MontoyaTech.MySqlPlus
{
//Get the current timestamp
ulong current = instance._Current;
+
//Compare it.
if (current > b)
return (current - b);
@@ -148,18 +147,7 @@ namespace MontoyaTech.MySqlPlus
///
~GlobalTimeStamp()
{
- try
- {
- if (this.Running)
- {
- this.Running = false;
-
- this.Watch.Stop();
-
- this.RefreshThread = null;
- }
- }
- catch { }
+ this.Dispose();
}
}
}
diff --git a/MySqlPlus/MySqlManagedConnection.cs b/MySqlPlus/MySqlManagedConnection.cs
index c40cb68..56023e3 100644
--- a/MySqlPlus/MySqlManagedConnection.cs
+++ b/MySqlPlus/MySqlManagedConnection.cs
@@ -49,27 +49,27 @@ namespace MontoyaTech.MySqlPlus
/// Creates a new managed MySqlConnection and sets its internal
/// MySql connection.
///
- ///
- public MySqlManagedConnection(MySqlConnection conn)
+ ///
+ public MySqlManagedConnection(MySqlConnection connection)
{
- if (string.IsNullOrWhiteSpace(conn.ConnectionString))
+ if (string.IsNullOrWhiteSpace(connection.ConnectionString))
throw new Exception("Connection string must be set on MySqlConnection.");
- this.MySqlConnection = conn;
- this.ConnectionString = conn.ConnectionString;
+ this.MySqlConnection = connection;
+ this.ConnectionString = connection.ConnectionString;
}
///
/// Creates a new managed MySqlConnection and setups up the internal connection string and gets everything ready.
///
- ///
- public MySqlManagedConnection(string conn)
+ ///
+ public MySqlManagedConnection(string connectionStr)
{
- if (string.IsNullOrWhiteSpace(conn))
+ if (string.IsNullOrWhiteSpace(connectionStr))
throw new Exception("Invalid connection string passed, it must not be null or empty.");
- this.MySqlConnection = new MySqlConnection(conn);
- this.ConnectionString = conn;
+ this.MySqlConnection = new MySqlConnection(connectionStr);
+ this.ConnectionString = connectionStr;
}
///
@@ -104,7 +104,7 @@ namespace MontoyaTech.MySqlPlus
else
throw new Exception("Failed to open a valid MySqlConnection.");
}
- catch (Exception ex)
+ catch
{
//See if we have reached our max retry.
if (i + 1 >= maxRetrys || !retry)
@@ -438,7 +438,7 @@ namespace MontoyaTech.MySqlPlus
///
~MySqlManagedConnection()
{
- Dispose();
+ this.Dispose();
}
}
}
diff --git a/MySqlPlus/MySqlPlus.csproj b/MySqlPlus/MySqlPlus.csproj
index 2af4f3e..58fb4f8 100644
--- a/MySqlPlus/MySqlPlus.csproj
+++ b/MySqlPlus/MySqlPlus.csproj
@@ -7,7 +7,7 @@
MontoyaTech.MySqlPlus
MontoyaTech.MySqlPlus
MontoyaTech.MySqlPlus
- 1.1.9
+ 1.2.0
MontoyaTech
A simple C# library to help work with MySql.
MontoyaTech 2023
@@ -27,7 +27,7 @@
-
+
diff --git a/MySqlPlus/MySqlSessionCache.cs b/MySqlPlus/MySqlSessionCache.cs
index df04017..783510d 100644
--- a/MySqlPlus/MySqlSessionCache.cs
+++ b/MySqlPlus/MySqlSessionCache.cs
@@ -25,16 +25,6 @@ namespace MontoyaTech.MySqlPlus
///
public DateTime LastUse = DateTime.MinValue;
- ///
- /// The method that requested this cache.
- ///
- public string CallerMethod = "";
-
- ///
- /// The line of code that requested this cache.
- ///
- public string CallerLine = "";
-
///
/// The Id of this CachedAPISession.
///
@@ -58,7 +48,7 @@ namespace MontoyaTech.MySqlPlus
///
public override void Dispose()
{
- InUse = false;
+ this.InUse = false;
//Set this again because we just stopped using this cached session.
this.LastUse = DateTime.UtcNow;
@@ -80,26 +70,31 @@ namespace MontoyaTech.MySqlPlus
///
private static Thread UnCacheThread = null;
+ ///
+ /// Whether or not the API Session Cache is running.
+ ///
+ private static bool Running = false;
+
///
/// The amount of time in minutes that a cached api session is allowed to live.
///
- private static int CacheLifeTime = 20;
+ public static int CacheLifeTime = 20;
///
/// The amount of time in minutes before a cache is considered to be a zombie
/// and the result of a code bug somewhere.
///
- private static int ZombieCacheLifeTime = 5;
+ public static int ZombieCacheLifeTime = 5;
///
/// The amount of time in seconds before we are allowed to attempt to uncache sessions.
///
- private static int UnCacheFrequency = 30;
+ public static int UnCacheFrequency = 30;
///
- /// Whether or not the API Session Cache is running.
+ /// Returns the next cached session.
///
- private static bool Running = false;
+ public static CachedMySqlSession Next => Get();
///
/// Starts this MySqlSessionCache with a given MySqlConnectionString.
@@ -218,18 +213,6 @@ namespace MontoyaTech.MySqlPlus
result.InUse = true;
result.LastUse = DateTime.UtcNow;
-
- //Get the caller information
- var trace = new StackTrace();
-
- var method = trace.GetFrame(1).GetMethod();
- var methodName = method.Name;
- var className = method.ReflectedType.Name;
- var currNamespace = method.ReflectedType.Namespace;
-
- result.CallerMethod = $"{currNamespace}.{className}.{methodName}()";
- result.CallerLine = trace.GetFrame(1).GetFileLineNumber().ToString();
-
return result;
}
}