Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Sushi Cache Path more customizeable #112

Merged
merged 3 commits into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/Sushi.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,29 @@ public static function resolveConnection($connection = null)
return static::$sushiConnection;
}

protected function sushiCachePath()
{
return implode(DIRECTORY_SEPARATOR, [
$this->sushiCacheDirectory(),
$this->sushiCacheFileName(),
]);
}

protected function sushiCacheFileName()
{
return config('sushi.cache-prefix', 'sushi').'-'.Str::kebab(str_replace('\\', '', static::class)).'.sqlite';
}

protected function sushiCacheDirectory()
{
return realpath(config('sushi.cache-path', storage_path('framework/cache')));
}

public static function bootSushi()
{
$instance = (new static);

$cacheFileName = config('sushi.cache-prefix', 'sushi').'-'.Str::kebab(str_replace('\\', '', static::class)).'.sqlite';
$cacheDirectory = realpath(config('sushi.cache-path', storage_path('framework/cache')));
$cachePath = $cacheDirectory.'/'.$cacheFileName;
$cachePath = $instance->sushiCachePath();
$dataPath = $instance->sushiCacheReferencePath();

$states = [
Expand Down Expand Up @@ -74,7 +90,7 @@ public static function bootSushi()
$states['cache-file-found-and-up-to-date']();
break;

case file_exists($cacheDirectory) && is_writable($cacheDirectory):
case file_exists($instance->sushiCacheDirectory()) && is_writable($instance->sushiCacheDirectory()):
$states['cache-file-not-found-or-stale']();
break;

Expand Down
Loading