1
0

pointers and hashing

This commit is contained in:
Antonio 2023-06-13 00:36:54 +08:00
parent 1425521d26
commit 0c2a0e72b3
2 changed files with 16 additions and 2 deletions

View File

@ -3,7 +3,7 @@ package bard
import "time"
type BardCache struct {
Bards map[string]Bard
Bards map[string]*Bard
}
func GarbageCollectCache(cache *BardCache) {
@ -18,7 +18,7 @@ var cache *BardCache
func init() {
cache = &BardCache{
Bards: make(map[string]Bard),
Bards: make(map[string]*Bard),
}
go func() {
for {

View File

@ -0,0 +1,14 @@
package bard
import (
"crypto/md5"
"encoding/hex"
)
func HashConversation(conversation []string) string {
hash := md5.New()
for _, message := range conversation {
hash.Write([]byte(message))
}
return hex.EncodeToString(hash.Sum(nil))
}