Git Product home page Git Product logo

counter-cache's Introduction

Counter Cache

Brings the ruby concept of "counter caching" to Laravel.

Total downloads Monthly downloads Latest release Open issues License Star repository on GitHub Watch repository on GitHub Fork repository on GitHub StyleCI

๐Ÿ“ Introduction

One thing we at Nodes have been missing in Laravel is the concept of "counter caching".

Laravel comes "out of the box" with the increment/decrement methods on it's Eloquent models. But you'll need to manually execute these methods everytime, you've saved/delete stuff with your model.

Since the increment/decrement methods always +1/-1, you can't 100% rely on these as cached value. What if you forgot to execute the decrement method when you deleted a row. Or what if someone deleted a row directly from the database, then your count would be "out of sync".

Therefore we've created this package which brings "counter caching" to Laravel.

The difference between this package and Laravel's increment/decrement is that our package actually generates and fires a SQL count statement, that counts the entries and updates the desired column with the result.

This way you're always 100% sure that the value in your "counter cache" column is correct.

๐Ÿ“ฆ Installation

To install this package you will need:

  • Laravel 5.1+
  • PHP 5.5.9+

You must then modify your composer.json file and run composer update to include the latest version of the package in your project.

"require": {
    "nodes/counter-cache": "^1.0"
}

Or you can run the composer require command from your terminal.

composer require nodes/counter-cache:^1.0

โš™ Usage

Please refer to the Wiki documentation for more information.

๐Ÿ† Credits

This package is developed and maintained by the PHP team at Nodes Agency

Follow Nodes PHP on Twitter Tweet Nodes PHP

๐Ÿ“„ License

This package is open-sourced software licensed under the MIT license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.