Git Product home page Git Product logo

Comments (5)

defunkt avatar defunkt commented on May 14, 2024

This variable is used. I've added a comment to explain: 0f296e3

Cheers!

from resque.

mrduncan avatar mrduncan commented on May 14, 2024

Unless I'm missing something, it looks like @watched_queues is only being read. I can't find anywhere that it's actually being set.

def watch_queue(queue)
  @watched_queues ||= {}
  return if @watched_queues[queue]  # <-- @watched_queues is always empty here
  redis.sadd(:queues, queue.to_s)
end

It seems like the following line should be added to actually cache the queue:

def watch_queue(queue)
  @watched_queues ||= {}
  return if @watched_queues[queue]
  redis.sadd(:queues, queue.to_s)
  @watched_queues[queue.to_s] = true  # <-- Cache it
end

Also, if the queue parameter is ever anything other than a string (I haven't checked to see if that actually ever happens), the following change should probably be made to avoid cache misses:

def watch_queue(queue)
  @watched_queues ||= {}
  return if @watched_queues[queue.to_s]  # <-- Get string for consistency
  redis.sadd(:queues, queue.to_s)
  @watched_queues[queue.to_s] = true
end

from resque.

defunkt avatar defunkt commented on May 14, 2024

You're right, looks like this needs a bugfix and a testcase.

from resque.

mrduncan avatar mrduncan commented on May 14, 2024

I made an attempt at a fix (mrduncan/resque@6e4233ea6d0b8cba6068f9bb05253470fd0f6253).

The only issue that I see with it is if a queue is removed it could still be in the cache of another process - seems like the Redis set which holds queue names might not get an entry for that queue if a new job is pushed.

from resque.

defunkt avatar defunkt commented on May 14, 2024

I think you're right about the other processes caching queues. Since this has never actually worked, it's probably a case of premature optimization. I removed it in 02a6ac1

Thanks!

from resque.

Related Issues (20)

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.