Ejemplo n.º 1
0
 private static void SetCachedResult(SqlCommand command, object value)
 {
     if (command.CommandType == CommandType.StoredProcedure && StoredProceduresToCache.ContainsKey(command.CommandText))
     {
         _cachedStoredProcedureResults[command] = new CachedResult
         {
             TimeAdded = DateTime.Now,
             Value     = value
         };
     }
 }
Ejemplo n.º 2
0
        private static object GetCachedResult(SqlCommand command)
        {
            if (command.CommandType == CommandType.StoredProcedure && StoredProceduresToCache.ContainsKey(command.CommandText))
            {
                CachedResult cachedResult;
                if (_cachedStoredProcedureResults.TryGetValue(command, out cachedResult))
                {
                    if (DateTime.Now.Subtract(cachedResult.TimeAdded) < StoredProceduresToCache[command.CommandText])
                    {
                        return(cachedResult.Value);
                    }
                    else
                    {
                        _cachedStoredProcedureResults.Remove(command);
                    }
                }
            }

            return(null);
        }