Cannot expire cache from background process?

Hello,

I am trying to expire fragments (or at least trigger their expiration)
from a daemon that’s running in the background.

The daemon is updating all kinds of important lists every few minutes
from the background.

So I have to find some way to DO or TRIGGER the fragment caching from
this daemon.

Unfortunately just using the normal commands like:

expire_fragment :controller => ‘groups’, :action => ‘index’

from within the daemon triggers no reaction. Is there anyting I could
change in the parameters I could add that would fix it?

Using a sweeper is a problem because the daemon updates a lot of models
but the cache should only be expired when a full round of updating is
completed – not with every single update of every single db entry. Fro
this purpose I created a Model to count the rounds - and then trigger
cache expiration after each ‘create’ of this counter. But this counter
model is not updated from any controller in the application - which - as
far as I understand it - is required to make the sweeper work.

Any help would be greatly appreciated!
Thanks!
Justus

Ok I’ll try to keep the question a bit shorter in the hope of increasing
the chances that somebody understands what my problem is:

How can I expire the fragement cache from a daemon located in my lib
folder?

This does not work:

expire_fragment :controller => ‘groups’, :action => ‘index’

Apparently the daemon cannot speak directly to the rails app? Or can I
fix it by modifying the parameters of the expire_fragment command?

Thanks,
Justus

Justus O. wrote:

Ok I’ll try to keep the question a bit shorter in the hope of increasing
the chances that somebody understands what my problem is:

How can I expire the fragement cache from a daemon located in my lib
folder?

Have you tried Rails.cache.delete(‘views/groups/index.html’)

(I think that’s the default path creation, given that you set the
config.cache_store properly in environment.rb)

Hey Justus,

Any luck with finding a solution? I’m in the same situation and need
to be able to run expire_fragment manually from the model or daemon.
Would love to know if you found a work around.

On Sep 30, 12:37 am, Justus O. <rails-mailing-l…@andreas-

Marston A. wrote:

Hey Justus,

Any luck with finding a solution? I’m in the same situation and need
to be able to run expire_fragment manually from the model or daemon.
Would love to know if you found a work around.

On Sep 30, 12:37�am, Justus O. <rails-mailing-l…@andreas-

No, I didn’t find a way to expire the cache from the daemon. My
workaround is to just let the fragments expire automatically by setting
a shorter expiration time in the memcached.yml. (for example, ttl: 300)
Justus

Ar Chron wrote:

Justus O. wrote:

Ok I’ll try to keep the question a bit shorter in the hope of increasing
the chances that somebody understands what my problem is:

How can I expire the fragement cache from a daemon located in my lib
folder?

Have you tried Rails.cache.delete(‘views/groups/index.html’)

(I think that’s the default path creation, given that you set the
config.cache_store properly in environment.rb)

Thanks, Ar. But unfortunately this doesn’t work either.

How would I set the config.cache_store properly? I have just used the
default setup. (except for setting
config.action_controller.perform_caching = true)

BTW. I would be fine with deleting the entire cache - no need for any
specifications. Shouldn’t that make it very easy??

Thanks again,
Justus