Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lfittl/async_counter_cache
(work in progress)
https://github.com/lfittl/async_counter_cache
Last synced: 21 days ago
JSON representation
(work in progress)
- Host: GitHub
- URL: https://github.com/lfittl/async_counter_cache
- Owner: lfittl
- License: mit
- Created: 2015-04-24T01:47:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-25T01:46:40.000Z (over 9 years ago)
- Last Synced: 2024-12-03T04:02:16.299Z (23 days ago)
- Language: Ruby
- Homepage:
- Size: 109 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# async_counter_cache
Re-implements the Rails counter cache's UPDATEs to happen outside of the primary transaction that changes a record. Since that is not atomic anymore, this uses a `COUNT(*)` on the association.
Due to its possible slowness this is run in an ActiveJob by default, meaning the count is not immediately updated.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'async_counter_cache'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install async_counter_cache
## Usage
```
has_many :posts, async_counter_cache: :posts_count
```## Contributing
1. Fork it ( https://github.com/lfittl/async_counter_cache/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request