lmarlow/resque-meta — Issue #9: expireat fails and meta data does not expire
Author: broglep-koubachi
Created: 2012-02-22 21:08:04+00:00
State: open

Hi

After some debugging I found a pretty nasty bug:

First of all, when storing the metadata, the wrong key ```"resque:#{key}"``` is used for the expireat call instead of ```key```

```
key = "meta:#{meta.meta_id}"
json = Resque.encode(meta.data)
Resque.redis.set(key, json)
Resque.redis.expireat("resque:#{key}", meta.expire_at) if meta.expire_at > 0
```

But it turns out that as long as you use resque with the default configuration with namespace "resque", everything works as expected.

Due to a bug in redis-namespace, the key passed to expireat is not prepended with the namespace (see https://github.com/defunkt/redis-namespace/pull/26), so the wrong key will actually be correct and everything works as expected.

but as soon as you deviate from the default configuration and use a custom namespace, expireat will silently fail because
- resque-meta uses the wrong key
- resque-namespace does not prepend the namespace to the wrong key
resulting in a completely wrong key,
and you begin to wonder why your memory usage of your redis instance steadily grows :)