Skip to content
This repository has been archived by the owner on Nov 27, 2021. It is now read-only.

请问下redis版本的GetOrSetFuncLock怎么没有实现lock功能 #5

Open
anythink-wx opened this issue Jun 21, 2021 · 0 comments
Open

Comments

@anythink-wx
Copy link

anythink-wx commented Jun 21, 2021

// GetOrSetFuncLock retrieves and returns the value of <key>, or sets <key> with result of
// function <f> and returns its result if <key> does not exist in the cache. The key-value
// pair expires after <duration>.
//
// It does not expire if <duration> == 0.
// It does nothing if function <f> returns nil.
//
// Note that the function <f> should be executed within writing mutex lock for concurrent
// safety purpose.
func (c *Redis) GetOrSetFuncLock(ctx context.Context, key interface{}, f func() (interface{}, error), duration time.Duration) (interface{}, error) {
	return c.GetOrSetFunc(ctx, key, f, duration)
}

代码里直接调用的 GetOrSetFunc 方法,导致并发的时候会穿透到底层

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

No branches or pull requests

1 participant