문제

Is there a way to pass object as arguments value in Resque-workers.

I want to do something like this Resque.enqueue(SomeWorker, obj) instead of Resque.enqueue(SomeWorker, id) my object is of different kind which does not have id.

Appreciate any help.

도움이 되었습니까?

해결책

as a best practice, you should never pass a real object to a worker.

the idea is that you pass a minimum of information to your worker, idealy an id, so that the worker can retrieve the rest of the information itself.

since the data is persisted in redis, you would actually need to somehow marshal your object when queuing it and then unmarshal it when the worker retrieves the data.

if your object is just holding some data you should think about passing this as a hash, cause they are easily persistable within redis.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top