Sha256: d4ae231730cf5a1c8fd4b48f65f57a0d525c889a266063e611454e9e82d81e34

Contents?: true

Size: 721 Bytes

Versions: 39

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

module LinkedRails
  class Cache
    extend RDF::Serializers::HextupleSerializer

    class << self
      def invalidate(iri)
        write([invalidate_resource(iri)])
      end

      def invalidate_all
        invalidate(Vocab.sp.Variable)
      end

      def write(delta)
        Redis.new.publish(
          ENV['CACHE_CHANNEL'],
          delta.map { |s| Oj.fast_generate(value_to_hex(*s)) }.join("\n")
        )
      end

      private

      def invalidate_resource(iri)
        [
          Vocab.sp.Variable,
          Vocab.sp.Variable,
          Vocab.sp.Variable,
          LinkedRails::Vocab.ontola["invalidate?graph=#{CGI.escape(iri)}"]
        ]
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
linked_rails-0.0.4.pre.g3aeec2263 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.gacd5f04d4 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.gb0b6aea40 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g792a1b887 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g58af47992 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g0ec6e30ca lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g9e3bcac55 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g222bfeeca lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.gb254a2893 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g2c6c26e86 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.ge881247c3 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.gfabf7e9f5 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g8c045be3a lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g8d7195543 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.gfe77aae19 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.gc866c1806 lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g3e8f5731a lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g58e27be7f lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g96885856b lib/linked_rails/cache.rb
linked_rails-0.0.4.pre.g1faca9643 lib/linked_rails/cache.rb