Documentation ¶
Index ¶
- Variables
- type Cache
- type DownloadError
- type FSCache
- func (c FSCache) Get(uri *url.URL) (matrix.File, error)
- func (c FSCache) GetThumbnail(url *url.URL, method matrix.ThumbnailMethod, width, height int) (matrix.Thumbnail, error)
- func (c FSCache) Put(uri *url.URL, file matrix.File) (<-chan int64, <-chan error)
- func (c FSCache) PutThumbnail(url *url.URL, method matrix.ThumbnailMethod, width, height int, ...) (<-chan int64, <-chan error)
- type MemoryCache
- func (c *MemoryCache) Get(uri *url.URL) (matrix.File, error)
- func (c *MemoryCache) GetThumbnail(uri *url.URL, method matrix.ThumbnailMethod, width, height int) (matrix.Thumbnail, error)
- func (c *MemoryCache) Put(uri *url.URL, file matrix.File) (<-chan int64, <-chan error)
- func (c *MemoryCache) PutThumbnail(uri *url.URL, method matrix.ThumbnailMethod, width, height int, ...) (<-chan int64, <-chan error)
- type StorageError
- type UsageError
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Put(*url.URL, matrix.File) (<-chan int64, <-chan error) // Get gets a file from the cache if it was put there. Get(url *url.URL) (matrix.File, error) PutThumbnail(url *url.URL, method matrix.ThumbnailMethod, width, height int, thumb matrix.Thumbnail) (<-chan int64, <-chan error) // Get gets a thumbnail from the cache if it was put there. GetThumbnail(url *url.URL, method matrix.ThumbnailMethod, width, height int) (matrix.Thumbnail, error) }
Cache specifies a common interface for caching content. Since mxc:// URIs are staic, a single Cache can be shared between multiple clients. A Cache implementation must be fully threadsafe. Resulting errors can be divided into three categories: error occured in download code (i.e connection lost), error occured in storing code (i.e insufficient permissions) or error occured due to incorrect usage of the Cache (i.e ErrCacheMiss, ErrAlreadyCached, ErrNotComplete). A error type exists for each category (DownloadError, StorageError, UsageError respectively). Implementations must use them.
type DownloadError ¶
type DownloadError struct {
Err error
}
DownloadError is returned by Cache when an error occures in the downloading code (i.e connection lost). It wraps the original error.
func (DownloadError) Error ¶
func (e DownloadError) Error() string
func (DownloadError) Unwrap ¶
func (e DownloadError) Unwrap() error
type FSCache ¶
type FSCache struct {
// contains filtered or unexported fields
}
FSCache stores content on the filesystem Files: $path/files/${url.Host}/${url.Path}/${file.Type}.${file.Name} Thumbnails: ${path}/thumbnails/${url.Host}/${url.Path}/${method}/${width}x${height}/${base64encode thumb.Type}
func NewFSCache ¶
func (FSCache) GetThumbnail ¶
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
func (*MemoryCache) GetThumbnail ¶
func (c *MemoryCache) GetThumbnail(uri *url.URL, method matrix.ThumbnailMethod, width, height int) (matrix.Thumbnail, error)
func (*MemoryCache) PutThumbnail ¶
func (c *MemoryCache) PutThumbnail(uri *url.URL, method matrix.ThumbnailMethod, width, height int, thumb matrix.Thumbnail) (<-chan int64, <-chan error)
type StorageError ¶
type StorageError struct {
Err error
}
StorageError is returned by Cache when an error occures in the storing code (i.e insufficient permissions). It wraps the original error.
func (StorageError) Error ¶
func (e StorageError) Error() string
func (StorageError) Unwrap ¶
func (e StorageError) Unwrap() error
type UsageError ¶
type UsageError struct {
Err error
}
UsageError is returned by Cache when an error due to incorrect usage of a Cache (i.e ErrCacheMiss, ErrNotCompleted). It wraps the original error.
func (UsageError) Error ¶
func (e UsageError) Error() string
func (UsageError) Unwrap ¶
func (e UsageError) Unwrap() error