You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stylesheet_cache.rb
    path of file: ./repos/discourse/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class StylesheetCache < ActiveRecord::Base
  self.table_name = "stylesheet_cache"

  MAX_TO_KEEP = 50
  CLEANUP_AFTER_DAYS = 150

  def self.add(target, digest, content, source_map, max_to_keep: nil)
    max_to_keep ||= MAX_TO_KEEP
    old_logger = ActiveRecord::Base.logger

    return false if where(target: target, digest: digest).exists
    
  def self.add(target, digest, content, source_map, max_to_keep: nil)
    max_to_keep ||= MAX_TO_KEEP
    old_logger = ActiveRecord::Base.logger

    return false if where(target: target, digest: digest).exists?

    ActiveRecord::Base.logger = nil if Rails.env.development?

    success = create(target: target, digest: digest, content: content, source_map: source_map)

    count = StylesheetCache.count
    if count > max_to_keep
      remove_lower =
        StylesheetCache.where(target: target).limit(max_to_keep).order("id desc").pluck(:id).last

      DB.exec(<<~SQL, id: remove_lower, target: target)
        DELETE FROM stylesheet_cache
        WHERE id < :id AND target = :target
      SQL
    end