Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Use MySQL, Sqlite, Postgres and Sqlsrv as cache Drivers. A more stable solution than @modulusphp's default file driver

License

Notifications You must be signed in to change notification settings

donaldp/database-cache-driver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Cache Driver for Modulus

This package enables your database connection(s) as cache drivers.

Install

Require the package with composer:

composer require don47/database-cache-driver

Install the package:

php craftsman plugin:install --class="\Don47\DatabaseCacheDriver\CachePlugin"

Register the plugin in the app config file:

'plugins' => [
  Don47\DatabaseCacheDriver\CachePlugin::class,
  ...
],

Append a new "fallback" cache connection in your cache config file:

'connections' => [
  'fallback' => [
    'driver' => 'database',
    'connection' => 'mysql'
  ],
  ...
],

Then run your migrations:

php craftsman migrate all

Change the default cache to fallback in the .env:

HIBERNATE_CACHE=fallback

Note: You can use any database connection. To get started, change the connection in the fallback config, then add protected $connection = 'connection_name'; in the _don47_database_cache_driver migration. Make sure this is done before running php craftsman migrate all.

Methods

Here are some methods to help you get started.

Name Helper Method Arguments Return Description
Cache::set() cache($key, $value, $expiration) string $key, mixed $value, ?Carbon $expiration bool Set or overwrite cache
Cache::forever() cache($key, $value) string $key, mixed $value bool Cache forever
Cache::get() cache($key) string $key mixed Get cached key
Cache::has() string $key bool Check if item is cached
Cache::forget() string $key bool Remove cached item
Cache::pull() string $key mixed Remove cached item

Security

If you discover any security related issues, please email donaldpakkies@gmail.com instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

About

Use MySQL, Sqlite, Postgres and Sqlsrv as cache Drivers. A more stable solution than @modulusphp's default file driver

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages