Skip to content

Commit

Permalink
Make Sushi Cache Path more customizeable (#112)
Browse files Browse the repository at this point in the history
* Make Sushi Cache Path more customizeable

This is useful if we want to change how the cache path generation is handled

* bugfix failed tests

* bugfix
  • Loading branch information
sawirricardo authored Jan 21, 2024
1 parent 503fa64 commit b362dd4
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/Sushi.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,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 @@ -75,7 +91,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

0 comments on commit b362dd4

Please sign in to comment.