Skip to content

MemCacheStore should send cache keys with TTL of 0 to memcached  #43619

@andrejbl

Description

@andrejbl

Memcached supports setting the TTL to 0 to cache the record permanently. However, trying to cache a value through MemCacheStore with exipres_in: 0 option instead causes the record to not be cached at all.

Steps to reproduce

(not providing a test for repro as it requires an externally running memcached server so it is not really self contained, hopefully this is ok as the repro steps are very basic)

Start a memcached server locally: memcached -p 11211

In a Rails console, run

cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, "localhost:11211", {})
cache.write("key", "value", :expires_in => 0)
cache.read("key") # this will return `nil`

Expected behavior

Entry should be cached indefinitely.

Actual behavior

Entry is not cached at all.

System configuration

Rails version: 6.1.4.1

Ruby version: 2.6.5

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions