@@ -26,9 +26,9 @@ public class BaseController : Controller, IDisposable
2626 {
2727 IServiceScope serviceScope ;
2828
29- public static string appversion => "147 " ;
29+ public static string appversion => "148 " ;
3030
31- public static string minorversion => "18 " ;
31+ public static string minorversion => "1 " ;
3232
3333 public HybridCache hybridCache { get ; private set ; }
3434
@@ -52,23 +52,26 @@ public BaseController()
5252 }
5353
5454 #region mylocalip
55+ static string lastMyIp = null ;
56+
5557 async public ValueTask < string > mylocalip ( )
5658 {
5759 string key = "BaseController:mylocalip" ;
58- if ( ! hybridCache . TryGetValue ( key , out string userIp ) )
60+ if ( ! memoryCache . TryGetValue ( key , out string userIp ) )
5961 {
6062 userIp = await InvkEvent . MyLocalIp ( new EventMyLocalIp ( requestInfo , HttpContext . Request , HttpContext , hybridCache ) ) ;
6163
62- if ( string . IsNullOrWhiteSpace ( userIp ) )
64+ if ( string . IsNullOrEmpty ( userIp ) )
6365 {
6466 var myip = await Http . Get < JObject > ( "https://api.ipify.org/?format=json" ) ;
65- if ( myip == null || string . IsNullOrWhiteSpace ( myip . Value < string > ( "ip" ) ) )
66- return null ;
67+ if ( myip == null || string . IsNullOrEmpty ( myip . Value < string > ( "ip" ) ) )
68+ return lastMyIp ;
6769
6870 userIp = myip . Value < string > ( "ip" ) ;
71+ lastMyIp = userIp ;
6972 }
7073
71- hybridCache . Set ( key , userIp , DateTime . Now . AddMinutes ( 15 ) ) ;
74+ memoryCache . Set ( key , userIp , DateTime . Now . AddMinutes ( 5 ) ) ;
7275 }
7376
7477 return userIp ;
0 commit comments