Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

[Patch] Added Global expires_in for cache_store

#2969

Patch allows mem_cache_store to have a default(global) expires_in parameter.

e.g
config.cache_store = :mem_cache_store, 'localhost:11211', {:expires_in => 1800}

From: Kevin Patel kevin@edge14.com and Joshua Borton digitaltoad@gmail.com

p.s. Moved expires_in method from cache.rb to mem_cache_store.rb as mem_cache is the only store that calls it.

Reported by CodeMonkeyKevin · July 28th, 2009 @ 11:55 PM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from cache, mem_cache to bugmash, cache, mem_cache

    September 25th, 2009 @ 01:01 PM

  2. Elad Meidar
    Elad Meidar

    +1 on idea, patch applies cleanly on 2-3-stable, tests pass (cause there aren't any :) ). Patch fails on master, i applied a patch too.
    I can't believe this was missing up until now, seems like a pretty mandatory fix.

    I can't seem to find a proper way to test it, can't find any recollection of expires_in tests in neither *_cache_test.rb test... ideas?

    September 25th, 2009 @ 03:56 PM

  3. jroes
    jroes

    I've attached a patch. The original patch moves the expires_in method to MemCacheStore. I preserved the original location in case another store needs to be able to default this. I also included a test.

    Notice This is my first Rails patch. Please give me all the tips and suggestions you can.

    September 26th, 2009 @ 09:20 PM

  4. Ben Marini
    Ben Marini

    -1 on implementation. After some thought, I don't think this fits with the current cache setting api, or belongs in activesupport.

    Currently, the api is:
    config.cache_store = [symbol_for_cache_class], [extra args passed to constructor]

    For example:
    ActionController::Base.cache_store = :mem_cache_store, "localhost"

    Thing is, MemCache does not take a default expires_in option in it's constructor. This functionality doesn't exist in the memcache-client gem. I think a better way to implement this would be a subclass of MemCache that accepts that option:
    config.cache_store = MemCacheWithDefaultExpires.new "localhost", :expires_in => 10.minutes

    Or submit this patch to the memcache-client gem. It's not Rails's responsibility to add extra functionality on top of caching implementations.

    September 26th, 2009 @ 11:27 PM

  5. John Guenin
    John Guenin

    -1 I agree with Ben. This functionality would make a great patch for the memcache-client gem, but does not belong in ActiveSupport.

    September 26th, 2009 @ 11:59 PM

  6. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from bugmash, cache, mem_cache to cache, mem_cache
    • State changed from new to wontfix

    Agreed. Good work, but this functionality belongs upstream from us.

    September 27th, 2009 @ 11:45 AM