# File lib/storage/cache.rb, line 151
  def get(oid)
    return nil if oid.nil?
    @st.inc(:reads)
    hv = hash(oid)

    # search the cache

    @cache[hv].each do |ce|
      if ce.oid == oid
        @st.inc(:cache_read_hits)
        # need to try putting hot hit to the head of the list?

        return ce.obj
      end
    end

    # cache miss - search the database

    if @db.has_key? oid.to_s
      ret = Utility.decode(@db[oid.to_s])
    else
      @st.inc(:database_read_fails)
      return nil
    end
    @st.inc(:database_reads)

    # get and remove the last entry off this list

    ch = @cache[hv].pop
    # if its dirty we write it to the database

    if ch.dirty? && !ch.dead?
      @db[ch.oid.to_s] = Utility.encode(ch.obj)
      @st.inc(:database_writes)
      if ch.noswap?  # here we have a problem we can't use this

        # first push it back onto the list

        @cache[hv].unshift ch
        # get ourselves a brand new

        ch = CacheEntry.new
        # problem solved

        # the depth of any list chains will be cache_depth + # noswap entries

      end
    end

    # assign our new object to the cache entry

    ch.obj = ret
    ch.oid = oid
    ch.clean!
    # push it to the head of the list

    @cache[hv].unshift ch

    ret
  end