]> git.lizzy.rs Git - go-anidb.git/commitdiff
anidb: Simplify documentation
authorDiogo Franco (Kovensky) <diogomfranco@gmail.com>
Mon, 15 Jul 2013 04:03:41 +0000 (01:03 -0300)
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>
Mon, 15 Jul 2013 04:03:41 +0000 (01:03 -0300)
anidb.go
animecache.go
episodecache.go
filecache.go
groupcache.go

index 1b69e714255c8ac729a9b42d044d9282a6a1fba1..bfe81d1ce1aa37867d7dbfd4e9da6fb3853c8d96 100644 (file)
--- a/anidb.go
+++ b/anidb.go
@@ -6,6 +6,10 @@ import (
 )
 
 // Main struct for the client, contains all non-shared state.
+//
+// All ObjectByKey methods (AnimeByID, GroupByName, etc) first try to read
+// from the cache. If the sought object isn't cached, or if the cache is
+// stale, then the appropriate API is queried.
 type AniDB struct {
        Timeout time.Duration // Timeout for the various calls (default: 45s)
 
index 66c1e6a601d8721143fdd349362cf52edee37006..2fd104428079a3418290e5fd77690472b63ef26e 100644 (file)
@@ -53,11 +53,8 @@ type httpAnimeResponse struct {
        err   error
 }
 
-// Retrieves an Anime from the cache if possible. If it isn't cached,
-// or if the cache is stale, queries both the UDP and HTTP APIs
-// for data.
-//
-// Note: This can take at least 4 seconds during heavy traffic.
+// Retrieves an Anime by its AID. Uses both HTTP and UDP APIs,
+// but can work without the UDP API.
 func (adb *AniDB) AnimeByID(aid AID) <-chan *Anime {
        keys := []cacheKey{"aid", aid}
        ch := make(chan *Anime, 1)
index 008dd98265c12353137b873156a72e25420aba4f..cfc44d98ffebbb41bbcd6491d95f00f3574ea552 100644 (file)
@@ -39,11 +39,7 @@ func cacheEpisode(ep *Episode) {
        cache.Set(ep, "eid", ep.EID)
 }
 
-// Retrieves the Episode from the cache if possible.
-//
-// If the result is stale, then queries the UDP API to
-// know which AID owns this EID, then gets the episode
-// from the Anime.
+// Retrieves an Episode by its EID.
 func (adb *AniDB) EpisodeByID(eid EID) <-chan *Episode {
        keys := []cacheKey{"eid", eid}
        ch := make(chan *Episode, 1)
index fbf7066966aa6db368c27d99a06250b76e42d4ac..10ba2ab7e6d47b43f67ea10ca5e5b3126b02dbd5 100644 (file)
@@ -80,9 +80,7 @@ func (f *File) Prefetch(adb *AniDB) <-chan *File {
        return ch
 }
 
-// Returns the File from the cache if possible.
-//
-// If the File is stale, then retrieves the File through the UDP API.
+// Retrieves a File by its FID.
 func (adb *AniDB) FileByID(fid FID) <-chan *File {
        keys := []cacheKey{"fid", fid}
 
@@ -127,9 +125,7 @@ func (adb *AniDB) FileByID(fid FID) <-chan *File {
        return ch
 }
 
-// Returns the File from the cache if possible.
-//
-// If the File is stale, then retrieves the File through the UDP API.
+// Retrieves a File by its Ed2kHash + Filesize combination.
 func (adb *AniDB) FileByEd2kSize(ed2k string, size int64) <-chan *File {
        keys := []cacheKey{"fid", "by-ed2k", ed2k, size}
 
index dbf30371ad8c08daa95980b4955820aba83b86bd..6cee34857ce210155a9b8f7ae4b08eb7e87c50b1 100644 (file)
@@ -56,10 +56,7 @@ func (c *gidCache) IsStale() bool {
        return true
 }
 
-// Returns a Group from the cache if possible.
-//
-// If the Group is stale, then retrieves the Group
-// through the UDP API.
+// Retrieves a Group by its GID.
 func (adb *AniDB) GroupByID(gid GID) <-chan *Group {
        keys := []cacheKey{"gid", gid}
        ch := make(chan *Group, 1)
@@ -101,6 +98,7 @@ func (adb *AniDB) GroupByID(gid GID) <-chan *Group {
        return ch
 }
 
+// Retrieves a Group by its name. Either full or short names are matched.
 func (adb *AniDB) GroupByName(gname string) <-chan *Group {
        keys := []cacheKey{"gid", "by-name", gname}
        altKeys := []cacheKey{"gid", "by-shortname", gname}