base64Captcha
base64Captcha copied to clipboard
Default Memory Store
in store_memory.go
we have defined functionality to get
and set
values.
It deletes the values from the store after GCLimitNumber
has reached and expiration time is over.
Issue:
- Captchas are present till GCLimitNumber of captchas are reached, even though captcha has expired and it will stay until garbage collected.
- Captchas might be retrieved again even though it might be expired.
**Proposal:**
Proposal 1:
While retrieving, we can check whether expired or not, if expired delete from store.
Proposal 2: We can create a wrapper structure over go-cache library.
- Advantage: It will take care of
Set, Get, and collect
functionality.
Hi, I would like to raise a PR w.r.t to proposal-2, I find it a better approach. Will it be a good way @slayercat @mojocn @JJJJJJJerk ?
Hi, I would like to raise a PR w.r.t to proposal-2, I find it a better approach. Will it be a good way @slayercat @mojocn @JJJJJJJerk ?
how aboud just use standard library sync.Map
We store the captcha in the memory for certain period of time expiry time
and then remove it right?
So, if we use sync.Map, here is my understanding
// digits structure
type Value Struct {
val interface{}
expiration int64
}
// map of id to value
sync.map[id]value
We can do get and set
for the values atomically.
But what about collection
we have to write separate logic for it and might want to use locks again?