Sha256: 70b1f3f4d644ab079e9be92a314eb272e72992cf9978c81934a1f59ae10a28f3

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

require_relative 'cache/version'
require_relative 'cache/settings'

require_relative 'cache/memcached'
require_relative 'cache/redis'

module Legion
  module Cache
    class << self
      include Legion::Cache::Memcached if Legion::Settings[:cache][:driver] == 'dalli'
      include Legion::Cache::Redis if Legion::Settings[:cache][:driver] == 'redis'

      def setup(**opts)
        return Legion::Settings[:cache][:connected] = true if connected?

        return unless client(**Legion::Settings[:cache], **opts)

        @connected = true
        Legion::Settings[:cache][:connected] = true
      end

      def shutdown
        Legion::Logging.info 'Shutting down Legion::Cache'
        close
        Legion::Settings[:cache][:connected] = false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
legion-cache-1.1.1 lib/legion/cache.rb
legion-cache-1.1.0 lib/legion/cache.rb