Skip to content

Gerando md5 para chaves de cache muito grandes#20

Merged
fabiobatalha merged 3 commits into
scieloorg:betafrom
fabiobatalha:tk19
Nov 13, 2015
Merged

Gerando md5 para chaves de cache muito grandes#20
fabiobatalha merged 3 commits into
scieloorg:betafrom
fabiobatalha:tk19

Conversation

@fabiobatalha
Copy link
Copy Markdown
Contributor

fix #19

Comment thread analytics/utils.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sería mejor crear hash para todo y regresarlos directamente y tal vez utilizar sha1 en lugar de md5
return hashlib.sha1(finalkey).hexdigest()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo pense en generar el hash solamente para los que exceden los bytes puesto que generar hash es un poco costoso, pero pondemos generar el hash para todos. Que piensas?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pues creo que por uniformidad estaría mejor, que sólo aplicar a las cadenas
que superen el límite
El El vie, 13 de noviembre de 2015 a la(s) 14:00, Fabio Batalha <
notifications@github.com> escribió:

In analytics/utils.py
#20 (comment):

@@ -26,7 +27,12 @@ def generate_key(_the_args, *_the_kwargs):
key += [str(i) for i in the_args[1:]]
key.append(str(the_kwargs))

  •    return "_".join(key)
    
  •    finalkey = "_".join(key)
    
  •    if len(finalkey) > 249:
    
  •        return hashlib.md5(finalkey).hexdigest()
    

Yo pense en generar el hash solamente para los que exceden los bytes
puesto que generar hash es un poco costoso, pero pondemos generar el hash
para todos. Que piensas?


Reply to this email directly or view it on GitHub
https://github.com/scieloorg/analytics/pull/20/files#r44827364.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, voy a cambiar.

http://www.sami-lehtinen.net/blog/python-hash-function-performance-comparison

Que piensas de utilizar el hash()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creo que para este caso será mejor utilizar un algoritmo ya sea md5 o sha
como que hash() no me convence mucho
El El vie, 13 de noviembre de 2015 a la(s) 14:11, Fabio Batalha <
notifications@github.com> escribió:

In analytics/utils.py
#20 (comment):

@@ -26,7 +27,12 @@ def generate_key(_the_args, *_the_kwargs):
key += [str(i) for i in the_args[1:]]
key.append(str(the_kwargs))

  •    return "_".join(key)
    
  •    finalkey = "_".join(key)
    
  •    if len(finalkey) > 249:
    
  •        return hashlib.md5(finalkey).hexdigest()
    

Ok, voy a cambiar.

http://www.sami-lehtinen.net/blog/python-hash-function-performance-comparison

Que piensas de utilizar el hash()


Reply to this email directly or view it on GitHub
https://github.com/scieloorg/analytics/pull/20/files#r44828511.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash es deterministico tanto cuanto md5 y sha1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perdón por la tardanza estaba en otros asuntos, respecto a la velocidad me parece bien y viendo mejor dentro de python el manejo se ajusta al objeto como tal, me parece bien (Y)

fabiobatalha added a commit that referenced this pull request Nov 13, 2015
Gerando md5 para chaves de cache muito grandes
@fabiobatalha fabiobatalha merged commit c28435f into scieloorg:beta Nov 13, 2015
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.

Chaves de cache superior a 250 caracteres.

2 participants