Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cache read twice for a single value #257

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

qichunren
Copy link
Contributor

No description provided.

@huacnlee
Copy link
Owner

It looks like no different?

@qichunren
Copy link
Contributor Author

class Hello

  def name
    puts "Try name"
    "Jim"
  end

  def call
    if name.nil?
      puts "name is nil"
    end
    puts "Name: #{name}"
  end

  def call_improve
    stored_value = name
    if stored_value.nil?
      puts "name is nil"
    end
    puts "Name: #{stored_value}"
  end
end

hello = Hello.new
puts "\nTest call"
hello.call
puts "\nTest call_improve"
hello.call_improve

Out put result:

Test call
Try name
Try name
Name: Jim

Test call_improve
Try name
Name: Jim

@huacnlee huacnlee changed the title Fixed #255 Fix cache read twice for a single value Dec 10, 2024
@huacnlee huacnlee merged commit 2969b02 into huacnlee:main Dec 10, 2024
11 checks passed
@huacnlee
Copy link
Owner

huacnlee commented Dec 10, 2024

Close #255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants