Sha256: 6a4ddd179ed856ee57d4dfb9bbdba308af38b5c58a70e87ef73f94cf34449258

Contents?: true

Size: 759 Bytes

Versions: 16

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

# Use CityHash for fast hashing if it is available; use Digest::MD5 otherwise
begin
  require "cityhash"
rescue LoadError
  unless RUBY_PLATFORM == "java"
    warn(<<-NOTICE)
      ** Notice: CityHash was not loaded. **

      For optimal performance, use of the cityhash gem is recommended.

      Run the following command, or add it to your Gemfile:

        gem install cityhash
    NOTICE
  end

  require "digest/md5"
end

module IdentityCache
  module CacheHash
    if defined?(CityHash)

      def memcache_hash(key) # :nodoc:
        CityHash.hash64(key)
      end
    else

      def memcache_hash(key) # :nodoc:
        a = Digest::MD5.digest(key).unpack("LL")
        (a[0] << 32) | a[1]
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
identity_cache-1.6.3 lib/identity_cache/cache_hash.rb
identity_cache-1.6.2 lib/identity_cache/cache_hash.rb
identity_cache-1.6.1 lib/identity_cache/cache_hash.rb
identity_cache-1.6.0 lib/identity_cache/cache_hash.rb
identity_cache-1.5.6 lib/identity_cache/cache_hash.rb
identity_cache-1.5.5 lib/identity_cache/cache_hash.rb
identity_cache-1.5.4 lib/identity_cache/cache_hash.rb
identity_cache-1.5.3 lib/identity_cache/cache_hash.rb
identity_cache-1.5.2 lib/identity_cache/cache_hash.rb
identity_cache-1.5.1 lib/identity_cache/cache_hash.rb
identity_cache-1.5.0 lib/identity_cache/cache_hash.rb
identity_cache-1.4.1 lib/identity_cache/cache_hash.rb
identity_cache-1.4.0 lib/identity_cache/cache_hash.rb
identity_cache-1.3.1 lib/identity_cache/cache_hash.rb
identity_cache-1.3.0 lib/identity_cache/cache_hash.rb
identity_cache-1.2.0 lib/identity_cache/cache_hash.rb