![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Wallet, a simple ruby DSL for centralizing action cache configuration inside your Rails app.
Wallet is a gem, available from http://rubygems.org.
Add the following to your Rails 3 app's Gemfile:
gem 'wallet', '~> 1.0.0.beta.2'
Let's imagine your app has a controller HomeController
, and you want to action cache the index action inside of it. First, create a config/wallet.rb
inside your rails root, then open your Wallet
and add some cash
:
Wallet.open do
cash :home do
index
end
end
Next, open your ApplicationController
, and add the following into it:
class ApplicationController < ActionController::Base
include Wallet::Cash
cash!
end
The cash!
method will setup action caching for your controllers (if they have any cache configuration in Wallet).
With this code in place, Rails will action cache the index
action inside your home controller for the default TTL (time-to-live) duration: 10 minutes. You can change the default ttl by passing a duration to the default_ttl
method:
Wallet.default_ttl = 2.minutes
Now, suppose we have another controller, ArticlesController
, and we want to cache the show
and index
actions on it for a duration of 20 minutes. Simple!
Wallet.open do
cash :articles, :for => 20.minutes do
show
index
end
end
This will cache only the show
and index
actions on the ArticlesController
.
Now imagine we've added a third action, comments
, to our ArticlesController
, and we want to cache it for only 1 minute:
Wallet.open do
cash :articles, :for => 20.minutes do
show
index
comments 1.minute
end
end
Sometimes, even though an action is cached, you want a before filter to run before Rails try's to serve out the cached response. Authentication is one common use case. You can accomplish this with Wallet by simply calling cash!
after the before filters:
class ApplicationController < ActionController::Base
include Wallet::Cash
before_filter :authentication
cash!
private
def authentication
#...
end
end
Now, the authentication
method will run before your before filters.
Wallet plays nice with engines. If you'd like to use Wallet inside your engine, create a config/wallet.rb
file inside your engine, then include Wallet::Railtie
inside your Engine railtie:
module Comments class Engine < Rails::Engine include Wallet::Railtie end end
Now, Rails will load the config/wallet.rb
inside your engine before your controllers load.
FAQs
Unknown package
We found that wallet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.