-
Notifications
You must be signed in to change notification settings - Fork 19
feat: Added a generic LRUCache interface and a default implementation #347
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
Conversation
jaeopt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - with a clarification
| } | ||
|
|
||
| // NewLRUCache returns a new instance of Least Recently Used in-memory cache | ||
| func NewLRUCache(size int, timeoutInSecs int64) LRUCache { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int64 to int? Range will be less than ~10000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid converting timeoutInSecs to in64 every time isValid is called since time.Now().Unix() returns a int64 value and calculations are only allowed between values of similar type's.
msohailhussain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address my comments and lgtm!!!
| Reset() | ||
| } | ||
|
|
||
| type cacheElement struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache ?
|
|
||
| // Cache is used for caching ODP segments | ||
| type Cache interface { | ||
| Save(key string, value interface{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add specific type of interface instead of interface{}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface has no further types in go.
| l.lock.Lock() | ||
| defer l.lock.Unlock() | ||
| if item, ok := l.items[key]; !ok { | ||
| if l.maxSize == len(l.items) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add comment. what this logic does.
msohailhussain
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Summary
Test plan
Included new tests in the test project
Issues
FSSDK-8513