Download the PHP package erjon/laravel-cache-groups without Composer

On this page you can find all versions of the php package erjon/laravel-cache-groups. 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 laravel-cache-groups

Laravel Cache Groups

Latest Version on Packagist Total Downloads

A Laravel package that adds cache()->groups() functionality to cache drivers that don't support cache()->tags(). This package provides a drop-in replacement for cache tags, making it work with all cache drivers including File, Database, and others that lack native tagging support.

Features

Why Cache Groups?

Laravel's cache()->tags() is powerful but only works with Redis, Memcached, and Array cache drivers. If you're using File or Database drivers, calling tags() throws a BadMethodCallException.

Cache Groups solves this by:

Comparison: Cache Tags vs Cache Groups

Feature cache()->tags() cache()->groups()
File Driver Support ❌ No ✅ Yes
Database Driver Support ❌ No ✅ Yes
Redis Support ✅ Yes ✅ Yes (delegates to tags)
Memcached Support ✅ Yes ✅ Yes (delegates to tags)
Array Driver Support ✅ Yes ✅ Yes (delegates to tags)
API Compatibility Standard 100% Compatible
Performance on Redis Optimal Optimal (uses native tags)
Performance on File N/A Good (explicit tracking)
Laravel Version 5.8+ 7.0+
Migration Effort N/A Replace tags() with groups()

Installation

Install the package via Composer:

The package will automatically register itself via Laravel's package auto-discovery.

Manual Registration (Laravel 5.x - 6.x)

If using older Laravel versions without auto-discovery, add the service provider to config/app.php:

Usage

Basic Usage

The API is identical to Laravel's cache()->tags():

Available Methods

All standard Laravel cache methods are supported:

Variadic Group Syntax

You can also pass groups as separate arguments:

How It Works

For Drivers Without Tag Support (File, Database)

Cache Groups tracks all keys belonging to each group:

  1. When you store a value: Cache::groups(['products'])->put('item:1', $data, 3600)

    • The key item:1 is added to the products group's key list
    • This list is stored in the cache at group:products:keys
  2. When you flush a group: Cache::groups(['products'])->flush()

    • All keys in the group's list are deleted
    • The group's key list itself is cleared
  3. When you forget a key: Cache::groups(['products'])->forget('item:1')
    • The key is removed from the cache
    • The key is removed from all group membership lists (prevents memory leaks)

For Drivers With Tag Support (Redis, Memcached, Array)

The package automatically detects if the cache driver supports tags and delegates to the native tags() implementation for better performance:

This ensures you get the best possible performance while maintaining API consistency.

Migration from Tags to Groups

If you're currently using cache()->tags() with Redis/Memcached and want to support File/Database drivers, simply replace tags() with groups():

Before:

After:

That's it! Your code now works with all cache drivers.

Performance Considerations

Key Tracking Overhead

When using drivers without native tag support (File, Database), the package tracks keys explicitly:

Best Practices

  1. Use Native Tags When Possible: If you're on Redis/Memcached, consider using cache()->tags() directly for maximum performance

  2. Limit Group Size: Try to keep groups under 10,000 keys for optimal performance

  3. Group Strategically: Organize your cache into logical groups that are flushed together

  4. Clean Up Manually: While the package removes keys from groups when using forget(), expired keys will remain in group lists until the group is flushed. Consider periodic group flushes for long-lived groups with high churn.

Testing

Run the test suite:

Requirements

License

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

Changelog

1.0.0 - Initial Release


All versions of laravel-cache-groups with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2|^8.0
laravel/framework Version ^7.0|^8.0|^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 erjon/laravel-cache-groups contains the following files

Loading the files please wait ...