class KnownClientMacOUI < ActiveRecord::Base
  belongs_to :organisation
 
  def update_redis
    org_key = organisation_id.present? ? organisation_id : "default"
    $redis.hset("org:#{org_key}:oui", mac_prefix, { manufacture: manufacture, hostname: hostname }.to_json) 
  end


  def remove_from_redis
    org_key = organisation_id.present? ? organisation_id : "default"
    $redis.hdel("org:#{org_key}:oui", mac_prefix)
  end

  after_save :update_redis
  after_destroy :remove_from_redis
  
end
