GitXplorerGitXplorer
t

gimme_a_break

public
1 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
f49f6eb835a62e8ad134c7e79a942200ac7e5eb1

removed gemspec

ttilsammans committed 13 years ago
Unverified
7d32f8246d8e539891e215a716b88fb614ef9fc3

release 1.0.0

ttilsammans committed 13 years ago
Unverified
160d072bf580c6a0e19763748c0b371e17316275

use rails syntax

ttilsammans committed 13 years ago
Unverified
daddf6b39c0a337b0e910bec0be0293bd0050eaa

ignore rvmrc

ttilsammans committed 13 years ago
Unverified
c7ea6ec85f0769838f52e95e744f1de0918b0969

only do something in rails prod env

ttilsammans committed 13 years ago
Unverified
286b147fd1f75ebc3b9f17aefdcbc6574302ed54

prepare to release new version

ttilsammans committed 13 years ago

README

The README file for this repository.

= Gimme A Break

This plugin adds a way to throttle ActiveRecord creation.

Add +gimme_a_break+ to your model to enable the throttling. It will then not be possible to create models in quick succession. Object creation is usually very "expensive" (in time) and blocks most database servers. Database IO is usually the bottleneck in web applications, and thottling this back is a great way to increase overall availability.

An error message will be added to the base object and the object will not be valid. It's up to you to display this error to the user. When you follow ActiveRecord convention you will be fine. The error message can be localized using the key gimme_a_break.notice with {{count}} as the timeout in seconds.

The throttle is applied per running instance. If you have two Passenger instances running, people will be able to create twice the amount of objects. This is exactly what you want, since the limit should scale linearly with the capacity of your servers. If your database keeps getting overloaded, reduce the timeout.

== Options

+timeout+: the time to wait between creates, in seconds. Default is 6.

== Prerequisites

Your model needs to have a created_at column for this to work. An index on it is highly recommended.

== Installation

Rails 2:

gem 'gimme_a_break', :version => "~> 0.2.0"

Rails 3:

gem 'gimme_a_break', '>= 1.0.0'

== Examples

class Comment < ActiveRecord::Base gimme_a_break end

class Tweet < ActiveRecord::Base gimme_a_break :timeout => 2 end

Copyright (c) 2011 Joost Baaij, released under the MIT license