summary refs log tree commit diff stats
path: root/cache/index.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-13 04:27:31 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-13 04:27:31 -0400
commit8af4945c9841b23224c6f76460278f67947fd01e (patch)
tree87ed7244030e66d5afa0bf307d1b94f4c09b85eb /cache/index.go
parentf06a2d6126bed22d38b506e1edc8822386a7cc33 (diff)
downloadgetwtxt-8af4945c9841b23224c6f76460278f67947fd01e.tar.gz
separating cache into its own library
Diffstat (limited to 'cache/index.go')
-rw-r--r--cache/index.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/cache/index.go b/cache/index.go
new file mode 100644
index 0000000..e0a3dd0
--- /dev/null
+++ b/cache/index.go
@@ -0,0 +1,20 @@
+package cache
+
+// NewUserIndex returns a new instance of a user index
+func NewUserIndex() *UserIndex {
+	return &UserIndex{}
+}
+
+// AddUser inserts a new user into the index. The *Data struct only contains the nickname.)
+func (index UserIndex) AddUser(nick string, url string) {
+	imutex.Lock()
+	index[url] = &Data{nick: nick}
+	imutex.Unlock()
+}
+
+// DelUser removes a user from the index completely.
+func (index UserIndex) DelUser(url string) {
+	imutex.Lock()
+	delete(index, url)
+	imutex.Unlock()
+}