Download the PHP package mahmoud217tr/cacheable without Composer

On this page you can find all versions of the php package mahmoud217tr/cacheable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cacheable

Cacheable for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Effortless and Enhanced Caching for Models and Classes

Laravel package that provides a streamlined and powerful solution for implementing caching within your application. This package simplifies the process of caching Eloquent models and other classes, ensuring improved performance and scalability for your Laravel application.

Table of Contents

Installation

To install the package to your Laravel project via Composer:

And once the installation is complete, the package will be ready up and ready for usage.

Usage

There is a lot of features and usecases we will summerize them with the following:

1. Cacheable Models

You can make the model cacheable by making it implement CacheableModel interface and use the CacheableModelTrait trait as the following example:

Upon doing that your model will be using the Cacheable Collection as a collection which extends the Eloquent Collection, preserving the same logic and providing the model with caching features.

Making a model cacheable will provide you with caching features:

1. Easy Caching for Model Records and Collections

You can easily cache individual model records or collections of records using the cache method as follows:

2. Auto-Caching Model Records

Models can be auto-cached, meaning all model records will be cached and synchronized upon creation, updating, or deletion.

CAUTION: This behavior may be unsuitable for large models or models with frequent changes. Use it wisely based on your use case.

To enable auto-caching, override the isAutoCacheSyncEnabled method in your model to return true:

Now, the auto-caching feature will be enabled, and all model records will be cached and updated automatically.

IMPORTANT: If you have modular Laravel application or you've changed your models default director, you'll need to do an extra step.

You can manage the cached models as follows:

You can also control the auto-cached collection by overriding the getDataForCaching method as it's default behaviour is to return the all method result:

And now only the published posts will cached by auto-caching feature and in order of the latest.

You can also control the TTL of the cached data by overriding the getCacheTTL method:

3. Cached Route Model Binding

You can also utilize the cached records to be used in route model binding by simply be using the CachedRouteBinding trait:

Note: Modifying the auto-cached data by overriding the getDataForCaching method may result in 404 Not Found for non-cached model records. Solutions for this scenario will be discussed further.

You can change the cached data that is used for route model binding by overriding 2 methods:

And now the data used for route model binding will be cached with a different key and have different values and will be synconized automatically.

When the usage of a different data for binding is enabled, you can control the TTL of the route binding cache by overriding the getBindingCacheTTL method:

You can also allow the model to use an alternative route binding method by overriding the shouldUseAlternativeRouteBinding method to return true:

The default alternative route binding resolver is the resolveRouteBinding method, which can be customized by overriding the alternativeRouteBinding method:

2. Cacheable Interface & Trait

You can easily make any thing cacheable by making it implements the Cacheable interface and use the CacahableTrait trait:

And you can use the cache function to store the object as follows:

3. Cacheable Facade

You can also utilize the Cacheable facade for some caching features, which has some drived features from the Cache facade:

4. Helper Functions

The package will give you a new helper functions:

  1. The is_cacheable_model helper function which checks if a mode or an instance of it implements the CacheableModel interface.
  2. The is_cacheable_class helper function which checks if a class or an instance of it implements the Cacheable interface.
  3. The cached helper function which retrieves cached data of a given key, but if not found, it will cache the given value by the given key with a given time to live if provided.

Publishing

To customize the package caching behavior you can publish the configuration file by running the following command in your console to copy the config file to your application's config directory:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of cacheable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^9.0|^10.0|^11.0
illuminate/support Version ^9.0|^10.0|^11.0
illuminate/cache Version ^9.0|^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mahmoud217tr/cacheable contains the following files

Loading the files please wait ....