-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Config for start options cache #36
Conversation
…okey/cache.go test: little chances to adapter new behavior gokey/cache_test.go refactor: change that functions hash to generate a callbacks gokey/hash.go test: little change in test TestGenerateMD5HashFromKey gokey/hash_test.go feat: new function to verified if user put the capacity of cache size gokey/helpers.go
refactor: delete variable err in hashFunc gokey/cache.go test: new test are add gokey/hash_test.go
test : new test are add gokey/hash_test.go
gokey/cache.go
Outdated
type Options struct { | ||
maxSize int | ||
aHast string | ||
tll float64 // in Newcache or their methods? |
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.
es TTL
gokey/cache.go
Outdated
@@ -27,11 +33,14 @@ var ( | |||
ErrExpiredKey = errors.New("key has expired") | |||
) | |||
|
|||
func newCache() *Cache { | |||
func newCache(o ...Options) *Cache { |
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.
tenemos que validar que options no venaga nil y/o vacio
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.
se me habia olvidado que options seria pasado por referencia, sorry.
gokey/cache.go
Outdated
maxSize int | ||
aHast string | ||
tll float64 // in Newcache or their methods? |
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.
- todos deben estar exportados, sino por fuera del paquete no van a poder llamarlo.
aHast
no entiendo que es, si es hash, no deberia ser un string sino algun tipo nuestro para que sea mas facil para el cliente y no dejarselo libre- Options tiene que tener godocs porque esta exportada
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.
- Ahash es el atributo de hash a elegir; "md5", "sha1" o "sha256".
Entiendo
var options *Options | ||
|
||
if len(o) < 1 || o[0] == nil { | ||
options = &Options{} |
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.
Aca deberias poner una por defecto.
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.
lo tomo en el proximo commit
Descripcion
Agregada la estructura Options que contendra los valores que seran pasados a la función newCache. Entre ellos están la capacidad maximá del cache, el algorithmo hash a utilizar y el TLL (aún no se donde deberia colocarlo).
agregados los test para los nuevos algorithmos, así como se refactorizo las funciones para agregar u/o quitar algunos hash.
Issue Relacionada
#28
Motivacion y Contexto
El cache se inicializaba con valores por defectos lo cual era rigido a la hora de querer una capidad máxima de
almacenamiento o algorithmo de cifrado. Con estos cambios haran que el usuario tenga mas libertad al decidir algunas
caracteriticas.
Aun permiten iniciar el cache con valores por defectos si no se pasan los argumentos al momento de instanciarlo.
Como fue probado
Se agregaron otros test para probar los nuevos hash
Screenshots / capturas de pantalla (si es necesario)
Tipo de cambio
Checklist
master
!.master
(lado izquierdo). Tambien de que estas usando los ultimos cambios enmaster
.go mod tidy && go mod vendor
go fmt -s
go vet