public DBTag this[string name] { get { if (String.IsNullOrWhiteSpace(name)) { return(null); } name = name.ToAlphaNumericLower(); Helpers.BlockUntilFinished(ref _initTask); if (_byName.TryGetValue(name, out var cached)) { return(cached.Item); } DateTime lastMiss = _nameMisses.GetValueOrDefault(name); if (lastMiss < DateTime.Now.AddSeconds(-MissExpireSecs)) { using (var cmd = DBTag.GetSqlCommandForSP_GetOne(Ctx, null, name)) { CachedEntry tag = AddTag(cmd.ExecuteReader_GetOne <DBTag>()); if (tag != null) { return(tag.Item); } } _nameMisses[name] = DateTime.Now; } return(null); } }
public DBTag this[long id] { get { if (id <= 0) { return(null); } Helpers.BlockUntilFinished(ref _initTask); if (_byId.TryGetValue(id, out var cached)) { return(cached.Item); } DateTime lastMiss = _idMisses.GetValueOrDefault(id); if (lastMiss < DateTime.Now.AddSeconds(-MissExpireSecs)) { using (var cmd = DBTag.GetSqlCommandForSP_GetOne(Ctx, id)) { CachedEntry tag = AddTag(cmd.ExecuteReader_GetOne <DBTag>()); if (tag != null) { return(tag.Item); } } _idMisses[id] = DateTime.Now; } return(null); } }