Skip to content

Commit 759e745

Browse files
committed
Update LaravelTwStreetname.php
1 parent 19a8e0d commit 759e745

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Seta0909/LaravelTwStreetname/LaravelTwStreetname.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ private static function getInstance()
3434
}
3535
else
3636
{
37-
self::$cache = 'none';
37+
session_start();
38+
self::$cache = 'session';
39+
self::$originData = $_SESSION['LaravelTwStreetnameOrigin'];
40+
self::$citys = $_SESSION['LaravelTwStreetnameCitys'];
41+
self::$countrys = $_SESSION['LaravelTwStreetnameCountrys'];
42+
self::$streets = $_SESSION['LaravelTwStreetnameStreets'];
43+
self::$zipCode = $_SESSION['LaravelTwStreetnameZipCode'];
3844
}
3945

4046
//載入街道Json資料
@@ -44,6 +50,8 @@ private static function getInstance()
4450
if(self::$cache=='apcache' && count(self::$originData) > 0)
4551
{
4652
apc_store('LaravelTwStreetnameOrigin', self::$originData);
53+
}else{
54+
$_SESSION['LaravelTwStreetnameOrigin'] = self::$originData;
4755
}
4856

4957
}
@@ -59,6 +67,8 @@ private static function getInstance()
5967
if(self::$cache=='apcache' && count(self::$zipCode) > 0)
6068
{
6169
apc_store('LaravelTwStreetnameZipCode', self::$zipCode);
70+
}else{
71+
$_SESSION['LaravelTwStreetnameZipCode'] = self::$zipCode;
6272
}
6373
}
6474

@@ -73,6 +83,8 @@ private static function getInstance()
7383
if(self::$cache=='apcache' && count(self::$citys) > 0)
7484
{
7585
apc_store('LaravelTwStreetnameCitys', self::$citys);
86+
}else{
87+
$_SESSION['LaravelTwStreetnameCitys'] = self::$citys;
7688
}
7789
}
7890
//載入鄉鎮區
@@ -83,6 +95,8 @@ private static function getInstance()
8395
if(self::$cache=='apcache' && count(self::$countrys) > 0)
8496
{
8597
apc_store('LaravelTwStreetnameCountrys', self::$countrys);
98+
}else{
99+
$_SESSION['LaravelTwStreetnameCountrys'] = self::$countrys;
86100
}
87101
}
88102
//載入街道
@@ -98,6 +112,8 @@ private static function getInstance()
98112
if(self::$cache=='apcache' && count(self::$streets) > 0)
99113
{
100114
apc_store('LaravelTwStreetnameStreets', self::$streets);
115+
}else{
116+
$_SESSION['LaravelTwStreetnameStreets'] = self::$streets;
101117
}
102118
}
103119
}

0 commit comments

Comments
 (0)