This repository was archived by the owner on Jun 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,12 @@ class API {
8282 */
8383 private $ session ;
8484
85+ /**
86+ * Key used to cache the session.
87+ * @var string
88+ */
89+ private $ cacheKey = "reflex:smite:session " ;
90+
8591 /**
8692 * Getter method for Dev Id
8793 * @return int
@@ -113,6 +119,13 @@ public function getCache() {
113119 return $ this ->cache ;
114120 }
115121
122+ /**
123+ * @return string
124+ */
125+ public function getCacheKey () {
126+ return $ this ->cacheKey ;
127+ }
128+
116129 /**
117130 * @return Session
118131 */
@@ -222,7 +235,7 @@ public function request($method) {
222235
223236 // check validity of session and create if needed
224237 if ($ request ->requiresSession () && (!$ this ->session || $ this ->session ->isExpired ())) {
225- $ this ->session = new Session ($ this );
238+ $ this ->session = new Session ($ this , $ this -> getCacheKey () );
226239 }
227240
228241 // get all extra args
Original file line number Diff line number Diff line change 88
99class Session {
1010 /**
11- * Change this to use a different key scheme for caching
1211 * @var string
1312 */
14- public static $ cachingKey = ' curse:smite:session ' ;
13+ public $ cacheKey ;
1514
1615 /**
1716 * Timestamp when session was created
@@ -28,9 +27,9 @@ class Session {
2827 /**
2928 * @param API $api
3029 */
31- function __construct (API $ api ) {
30+ function __construct (API $ api, $ cacheKey ) {
3231 $ this ->api = $ api ;
33- self :: $ cachingKey = self :: $ cachingKey . ': ' . md5 ($ api ->getPlatform ());
32+ $ this -> cacheKey = $ cacheKey . ': ' . md5 ($ api ->getPlatform ());
3433 if (!$ this ->loadFromCache ()) {
3534 $ this ->createSession ();
3635 }
@@ -67,7 +66,7 @@ private function loadFromCache() {
6766 if (!$ this ->api ->getCache ()) {
6867 return false ;
6968 }
70- $ data = $ this ->api ->getCache ()->fetch (self :: $ cachingKey );
69+ $ data = $ this ->api ->getCache ()->fetch ($ this -> cacheKey );
7170 if ($ data ) {
7271 list ($ this ->sessionKey , $ this ->sessionTimestamp ) = unserialize ($ data );
7372 return !$ this ->isExpired ();
@@ -85,7 +84,7 @@ private function saveToCache() {
8584 }
8685 $ data = serialize ([$ this ->sessionKey , $ this ->sessionTimestamp ]);
8786 // save for 15 minutes
88- $ this ->api ->getCache ()->save (self :: $ cachingKey , $ data , $ this ->api ->sessionTTL ());
87+ $ this ->api ->getCache ()->save ($ this -> cacheKey , $ data , $ this ->api ->sessionTTL ());
8988 }
9089
9190 /**
You can’t perform that action at this time.
0 commit comments