Skip to content

@npj /gist:2596220
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class Slug
class << self
def [](slug)
redis.hget(hash, slug)
end
def []=(slug, id)
if old = self[slug]
redis.srem(set(old), slug)
end
redis.hset(hash, slug, id)
redis.sadd(set(id), slug)
end
def destroy(id)
redis.smembers(set(id)).each { |slug| redis.hdel(hash, slug) }
redis.del(set(id))
end
private
def redis
$redis
end
def hash
"post_ids"
end
def set(id)
"post_slugs_#{id}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.