Sha256: 61f06124967f2dd1b48334ab5915f2180c0ef1c56a9df050ce74876031f5267d

Contents?: true

Size: 726 Bytes

Versions: 14

Compression:

Stored size: 726 Bytes

Contents

# 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

14 entries across 14 versions & 1 rubygems

Version Path
identity_cache-0.5.1 lib/identity_cache/cache_hash.rb
identity_cache-0.5.0 lib/identity_cache/cache_hash.rb
identity_cache-0.4.1 lib/identity_cache/cache_hash.rb
identity_cache-0.4.0 lib/identity_cache/cache_hash.rb
identity_cache-0.3.2 lib/identity_cache/cache_hash.rb
identity_cache-0.3.1 lib/identity_cache/cache_hash.rb
identity_cache-0.3.0 lib/identity_cache/cache_hash.rb
identity_cache-0.2.5 lib/identity_cache/cache_hash.rb
identity_cache-0.2.4 lib/identity_cache/cache_hash.rb
identity_cache-0.2.3 lib/identity_cache/cache_hash.rb
identity_cache-0.2.2 lib/identity_cache/cache_hash.rb
identity_cache-0.2.1 lib/identity_cache/cache_hash.rb
identity_cache-0.2.0 lib/identity_cache/cache_hash.rb
identity_cache-0.1.0 lib/identity_cache/cache_hash.rb