2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-27 20:14:06 -04:00
|
|
|
class Developer < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
|
|
|
|
|
|
|
after_save :rebuild_cache
|
|
|
|
after_destroy :rebuild_cache
|
|
|
|
|
|
|
|
@id_cache = DistributedCache.new('developer_ids')
|
|
|
|
|
|
|
|
def self.user_ids
|
2016-07-27 20:20:29 -04:00
|
|
|
@id_cache["ids"] || rebuild_cache
|
2016-07-27 20:14:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.rebuild_cache
|
|
|
|
@id_cache["ids"] = Set.new(Developer.pluck(:user_id))
|
|
|
|
end
|
|
|
|
|
|
|
|
def rebuild_cache
|
|
|
|
Developer.rebuild_cache
|
|
|
|
end
|
|
|
|
end
|
2016-08-15 03:44:24 -04:00
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: developers
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# user_id :integer not null
|
|
|
|
#
|