Documentation
¶
Index ¶
- type FilesystemStore
- func (fs *FilesystemStore) Close() error
- func (fs *FilesystemStore) Delete(id string) error
- func (fs *FilesystemStore) Exists(id string) (bool, error)
- func (fs *FilesystemStore) Get(id string) (*models.Paste, error)
- func (fs *FilesystemStore) GetContent(id string) ([]byte, error)
- func (fs *FilesystemStore) GetContentPrefix(id string, n int64) ([]byte, error)
- func (fs *FilesystemStore) IncrementReadCount(id string) error
- func (fs *FilesystemStore) StatContent(id string) (bool, int64, error)
- func (fs *FilesystemStore) Store(paste *models.Paste) error
- func (fs *FilesystemStore) StoreContent(id string, content []byte) error
- type PasteStore
- type S3Store
- func (s *S3Store) Close() error
- func (s *S3Store) Delete(id string) error
- func (s *S3Store) Exists(id string) (bool, error)
- func (s *S3Store) Get(id string) (*models.Paste, error)
- func (s *S3Store) GetContent(id string) ([]byte, error)
- func (s *S3Store) GetContentPrefix(id string, n int64) ([]byte, error)
- func (s *S3Store) IncrementReadCount(id string) error
- func (s *S3Store) StatContent(id string) (bool, int64, error)
- func (s *S3Store) Store(paste *models.Paste) error
- func (s *S3Store) StoreContent(id string, content []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilesystemStore ¶
type FilesystemStore struct {
// contains filtered or unexported fields
}
FilesystemStore stores paste metadata and content on the local filesystem.
func NewFilesystemStore ¶
func NewFilesystemStore(dataDir string) (*FilesystemStore, error)
NewFilesystemStore creates a FilesystemStore for the given data directory. If dataDir is empty it defaults to "./data". The directory is created if it does not exist.
func (*FilesystemStore) Close ¶
func (fs *FilesystemStore) Close() error
func (*FilesystemStore) Delete ¶
func (fs *FilesystemStore) Delete(id string) error
func (*FilesystemStore) GetContent ¶
func (fs *FilesystemStore) GetContent(id string) ([]byte, error)
func (*FilesystemStore) GetContentPrefix ¶ added in v0.9.8
func (fs *FilesystemStore) GetContentPrefix(id string, n int64) ([]byte, error)
GetContentPrefix reads up to n bytes from the content file. If the file is smaller than n, it returns the full content.
func (*FilesystemStore) IncrementReadCount ¶
func (fs *FilesystemStore) IncrementReadCount(id string) error
func (*FilesystemStore) StatContent ¶ added in v0.9.10
func (fs *FilesystemStore) StatContent(id string) (bool, int64, error)
StatContent reports whether content exists on disk and its size.
func (*FilesystemStore) Store ¶
func (fs *FilesystemStore) Store(paste *models.Paste) error
Store saves the paste metadata (JSON) to local filesystem
func (*FilesystemStore) StoreContent ¶
func (fs *FilesystemStore) StoreContent(id string, content []byte) error
type PasteStore ¶
type PasteStore interface {
// Store saves a paste to the storage backend
Store(paste *models.Paste) error
// Get retrieves a paste by its ID
Get(id string) (*models.Paste, error)
// Exists checks if a paste exists by its ID
Exists(id string) (bool, error)
// Delete removes a paste from storage
Delete(id string) error
// IncrementReadCount increments the read count for a paste
IncrementReadCount(id string) error
// Close closes the storage connection
Close() error
// StoreContent saves the raw content for a paste
StoreContent(id string, content []byte) error
// GetContent retrieves the raw content for a paste
GetContent(id string) ([]byte, error)
// GetContentPrefix retrieves up to n bytes of the raw content for a paste.
// Implementations should return as many bytes as are available up to n.
GetContentPrefix(id string, n int64) ([]byte, error)
// StatContent reports whether content exists and its size. Implementations
// should return (false, 0, nil) when the content does not exist.
// This is used by handlers to perform early size checks without
// retrieving the entire object.
StatContent(id string) (exists bool, size int64, err error)
}
PasteStore defines the interface for paste storage backends
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
func NewS3Store ¶
NewS3Store creates a new S3Store instance
func (*S3Store) GetContentPrefix ¶ added in v0.9.8
GetContentPrefix retrieves up to n bytes from an S3 object using Range header.
func (*S3Store) IncrementReadCount ¶
func (*S3Store) StatContent ¶ added in v0.9.10
StatContent checks if the object exists in S3 and returns its size.