cache icon indicating copy to clipboard operation
cache copied to clipboard

Add a NullStore

Open pnomolos opened this issue 10 years ago • 0 comments

@seamusabshere Would you be open to a PR that adds a NullStore to the list of valid adapters? Would be really helpful for testing and such :). Something like the following (I need to verify that the return values for these are consistent with the rest of the adapters):

class Cache
  module NullStore
    def after_fork
      # no-op
    end

    def _get(k)
      # no-op
    end

    def _get_multi(ks)
      # no-op
    end

    def _set(k, v, ttl)
      v
    end

    def _delete(k)
      true
    end

    def _flush
      true
    end

    def _exist?(k)
      false
    end

    def _stats
      nil
    end

    def fetch(k, ttl = nil, &blk)
      blk.call
    end

    def cas(k, ttl = nil, &blk)
      blk.call
    end
  end
end

pnomolos avatar Nov 14 '15 01:11 pnomolos