Giter Site home page Giter Site logo

cashier's People

Contributors

amoslanka avatar kensodev avatar parndt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cashier's Issues

uninitialized class variable @@adapter in Cashier

I'm trying to use this Gem with no luck - I can't figure out from the documentation if I'm using it correctly.

I have an products index, with various combinations of query strings. I would like to cache these all under a tag, and then clear all cached items in a tag when a product is changed, removed or added.

In my Products controller I have:

class ProductsController < ApplicationController
   caches_action :index, :cache_path => Proc.new { |c| c.params }, :tag => "products"
   cache_sweeper :product_sweeper #Products sweeper will use Cashier.expire "products" if needed

   def index
      # rest of code
   end
end

When trying to use Cashier as above, I get the following:

uninitialized class variable @@adapter in Cashier

What am I doing wrong? Any help would be greatly appreciated.

NoMethodError (undefined method `current_user' for #<MyController...>)

In application.rb, I define a "current_user" method, which is necessary for how I do authentication (SimplestAuth) & authorization (declarative_authorization).

When I add cashier to my Gemfile and run bundle install, suddenly I start getting 500's and a NoMethodError for current_user. Reverting the Gemfile and removing the vendored cashier gem — and making no other changes — makes the NoMethodError go away again.

undefined method `cashier'

Trying to use this cool gem, but I am struggling starting my application with it (am I missing something simple here?).
I added the cashier gem to my Gemfile and I also added the following to my development.rb file:

config.cashier.adapter.redis = REDIS_OBJ_HERE

I am getting the following error when running my rails server:

undefined method `cashier' for #<Rails::Application::Configuration:0x007fdfd11bdc18>
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/railtie/configuration.rb:85:in `method_missing'
/Users/michael/Projects/mixellent/config/environments/development.rb:58:in `block in <top (required)>'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:24:in `class_eval'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:24:in `configure'
/Users/michael/Projects/mixellent/config/environments/development.rb:1:in `<top (required)>'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/engine.rb:571:in `block in <class:Engine>'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
/Users/michael/.rvm/gems/ruby-1.9.3-p0@rails326/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/michael/Projects/mixellent/config/environment.rb:5:in `<top (required)>'

Note: I am using Rails 3.2.6 on Ruby 1.9.3.

Thanks,

Michael

Integrating Rails.cache through Cashier

Hey,

I want to add integration to Rails.cache through cachier.

Meaning, every time you call Rails.cache.fetch with tags, you will go through cashier, also, every time you delete a cache key, you invalidate the tags for it.

What do you think is the best way to integrate through Rails.cache?

I tried opening the dalli_store class but it fails for some reason.

Would love your thoughts.

ActiveSupport Notification for tag expire

Would love to see a notification set up for when a tag gets expired. I particularly use the notifications for outputting to my logs, which is the most common method i use on cashier that would be nice to have notification on. Does this fit the expected use of the notifications?

Tag as a proc in caches_action etc won't get called

Trying to set a tag in a controller action with a proc won't work

caches_action :tag => proc {|c|
  # c is the controller
  "users/#{c.current_user.id}/dashboard"      
}

There's no code within action pack (Rails 3.2.9) that will evaluate a proc for tag. It just gets past along as a store_option which you can see here. There also doesn't seem to be a way to evaluate the proc later on in the cashier code because you don't have the controller to execute it from.

In previous versions of Rails did all procs passed to caches_action get evaluated somewhere?

Current version of gem doesn't work

The currently released version of the gem (0.4.0) doesn't work unless I open up the downloaded gem, and add

ActiveSupport::Cache::Store.instrument = true
  ActiveSupport::Notifications.subscribe("cache_write.active_support") do |*args|
  payload = ActiveSupport::Notifications::Event.new(*args).payload
  Cashier.store_fragment payload[:key], payload[:tag] if payload[:tag]
end

to the bottom of lib/cashier.rb. If I instead point my Gemfile to your git repo then Cashier works. I notice there's a couple of weeks difference between the last gem release and when you added the above lines to lib/cashier.rb.

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.