Skip to content

Commit e9df6e1

Browse files
committed
Change default to cache token, since not caching it seems to be a major performance problem in some cases and everyone should take this option by default
1 parent ad7aa6e commit e9df6e1

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ You may use the following code block below as a template, which has some good de
7878
'prefix' => env('DB_PREFIX', ''),
7979
'version' => env('DB_VERSION', 'vLatest'),
8080
'protocol' => env('DB_PROTOCOL', 'https'),
81-
'cache_session_token' => env('DB_CACHE_SESSION_TOKEN', true), // set to true to cache the session token between requests and prevent the need to re-login each time. This can be a significant performance improvement!
81+
'cache_session_token' => env('DB_CACHE_SESSION_TOKEN', true), // set to false to log out after each reqeust. This can be slower than re-using a session token, but allows for globals to be set for individual user values.
8282
'empty_strings_to_null' => env('DB_EMPTY_STRINGS_TO_NULL', true), // set to false to return empty strings instead of null values when fields are empty in FileMaker
8383
]
8484
```

src/Middleware/EndSession.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public function handle(Request $request, Closure $next): Response
2727
*/
2828
public function terminate(Request $request, Response $response): void
2929
{
30-
$shouldCacheSessionToken = FM::connection()->getConfig()['cache_session_token'] ?? false;
30+
$shouldCacheSessionToken = FM::connection()->getConfig()['cache_session_token'] ?? true;
31+
// don't close the connection if we're caching the session token
3132
if ($shouldCacheSessionToken) {
3233
return;
3334
}

src/Services/FileMakerConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct($pdo, $database = '', $tablePrefix = '', array $conf
4444
{
4545

4646
$this->emptyStringToNull = $config['empty_strings_to_null'] ?? true;
47-
$this->shouldCacheSessionToken = $config['cache_session_token'] ?? false;
47+
$this->shouldCacheSessionToken = $config['cache_session_token'] ?? true;
4848

4949
// set the session cache key with the name of the connection to support multiple connections
5050
$this->sessionTokenCacheKey = 'eloquent-filemaker-session-token-' . $config['name'];

0 commit comments

Comments
 (0)