Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
calebporzio committed Aug 12, 2021
1 parent ce39a25 commit 75a2418
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Role extends Model
By default, Sushi looks at the "last modified" timestamp of your model PHP file and compares it with its internal `.sqlite` cache file. If the model file has been changed more recently than the `.sqlite` cache file, then Sushi will destroy and rebuild the `.sqlite` cache.
Additionally, you can configure an external file for Sushi to reference when determining if the cache is up to date or needs to be refreshed.

If, for example, you are using Sushi to provide an Eloquent model for an external data source file like an `.csv` file, you can use `sushiModelPath` to force Sushi to reference the `.csv` file when determining if the cache is stale.
If, for example, you are using Sushi to provide an Eloquent model for an external data source file like an `.csv` file, you can use `sushiCacheReferencePath` to force Sushi to reference the `.csv` file when determining if the cache is stale.

For example:

Expand All @@ -194,7 +194,7 @@ class Role extends Model
return true;
}

protected function sushiModelPath()
protected function sushiCacheReferencePath()
{
return __DIR__.'/roles.csv';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sushi.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getSchema()
return $this->schema ?? [];
}

protected function sushiModelPath()
protected function sushiCacheReferencePath()
{
return (new \ReflectionClass(static::class))->getFileName();
}
Expand All @@ -43,7 +43,7 @@ public static function bootSushi()
$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;
$dataPath = $instance->sushiModelPath();
$dataPath = $instance->sushiCacheReferencePath();

$states = [
'cache-file-found-and-up-to-date' => function () use ($cachePath) {
Expand Down

0 comments on commit 75a2418

Please sign in to comment.