+++ /dev/null
-<?php
-
-namespace Cubist\Backpack;
-
-class Cache extends \Illuminate\Support\Facades\Cache
-{
- public static function rememberOrRefresh(string $key, \DateTimeInterface|\DateInterval|int $ttl, \Closure $callback, $refresh = false)
- {
- if ($refresh) {
- $data = $callback();
- self::put($key, $data, $ttl);
- return $data;
- } else {
- return self::remember($key, $ttl, $callback);
- }
- }
-}
--- /dev/null
+<?php
+
+namespace Cubist\Backpack\Cache;
+use Closure;
+
+class CacheManager extends \Illuminate\Cache\CacheManager
+{
+
+ public function rememberOrRefresh($key, $ttl, Closure $callback, $refresh = false)
+ {
+ if ($refresh) {
+ $data = $callback();
+ $this->put($key, $data, $ttl);
+ return $data;
+ }
+ return $this->remember($key, $ttl, $callback);
+ }
+}
namespace Cubist\Backpack;
+use Cubist\Backpack\Cache\CacheManager;
use Cubist\Backpack\Console\Commands\MigrateCommand;
use Cubist\Backpack\Console\Commands\GenerateCommand;
use Cubist\Backpack\Console\Commands\InstallCommand;
use Cubist\Backpack\Console\Commands\LocaleCopy;
use Cubist\Backpack\Console\Commands\LocaleSlugReset;
-use Cubist\Backpack\Console\Commands\PrecacheCommand;
use Cubist\Backpack\Console\Commands\RefreshComposedAttributesCommand;
use Cubist\Backpack\Console\Commands\SearchIndexCommand;
use Cubist\Backpack\Console\Commands\UpdateCommand;
$configs = ['app', 'cubist'];
+ $this->app->singleton('cache', function ($app) {
+ return new CacheManager($app);
+ });
+
foreach ($configs as $config) {
$this->mergeConfigFrom($resourcesDir . '/config/' . $config . '.php', $config);
}
RefreshComposedAttributesCommand::class,
SearchIndexCommand::class,
LocaleCopy::class,
- LocaleSlugReset::class,
- PrecacheCommand::class
+ LocaleSlugReset::class
]);
}
+
+ public function provides()
+ {
+ return ['cache'];
+ }
}