Skip to content

Cache::memo()->many() not returning the same result as Cache::many() #55500

Closed
@bmckay959

Description

@bmckay959

Laravel Version

12.9.2

PHP Version

8.4

Database Driver & Version

No response

Description

Currently, the value of Cache::memo()->many(['1']) returns a different value than Cache::many(['1'])

Interestingly enough, when the 'key' is not an integer or an integer stored as a string, it works just fine.

Code to Reproduce(Repo included below)

$data = [
    'a' => 'string-value',
    '1.1' => 'float-value',
    '1' => 'integer-value-as-string',
    2 => 'integer-value'
];

// Store the above array into the cache
// This works as expected
Cache::memo()->putMany($data);

$this->info('Expected results with or without memo');
// Retrieve data without "memo()"
// This works as expected
dump(Cache::many(['a', '1.1', '1', 2]));

$this->info('Actual results with memo');
// Retrieve data with "memo()"
// This does not work as expected when the key is an integer or integer as a string
dump(Cache::memo()->many(['a', '1.1', '1', 2]));

Expected results with or without memo

$result = [
  "a" => "string-value"
  "1.1" => "float-value"
  1 => "integer-value-as-string"
  2 => "integer-value"
];

Actual results with memo

$result = [
  "a" => "string-value"
  "1.1" => "float-value"
  1 => "integer-value"
  2 => 3
  0 => "integer-value-as-string"
];

Steps To Reproduce

Pull the repo to reproduce: https://github.com/bmckay959/bug-report

Then, run the following command: php artisan app:memo-test-command

You will see 2 outputs:

  1. The first output shows what Cache::many() returns. (Notice this does not include memo)
  2. The second output shows what Cache::memo()->many() returns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions