pkg

package
v0.0.0-...-087be1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a simple in-memory cache implementation. It utilizes a sync.RWMutex for concurrent read and write safety. The cache stores data as byte slices, using string keys for retrieval.

func NewCache

func NewCache() *Cache

New creates and returns a new instance of the Cache with initialized internal data. The Cache is an in-memory cache implementation using a sync.RWMutex for concurrency safety. The internal data is represented as a map with string keys and byte slice values.

func (*Cache) Delete

func (c *Cache) Delete(key []byte) error

Delete removes the specified key from the cache. It acquires a write lock to ensure concurrent safety during deletion. The method returns nil, indicating a successful deletion.

func (*Cache) Get

func (c *Cache) Get(key []byte) ([]byte, error)

Get retrieves the value associated with the specified key from the cache. It acquires a read lock to ensure concurrent safety during retrieval. If the key is not found, an error is returned indicating the absence of the key. The retrieved value and a nil error are returned if the key is present in the cache.

func (*Cache) Has

func (c *Cache) Has(key []byte) bool

Has checks if the specified key exists in the cache. It acquires a read lock to ensure concurrent safety during the lookup. The method returns true if the key is found in the cache, and false otherwise.

func (*Cache) Set

func (c *Cache) Set(key, value []byte, ttl time.Duration) error

Set adds or updates the cache with the specified key-value pair. It acquires a write lock to ensure concurrent safety during insertion. If the time-to-live (TTL) duration is greater than zero, a goroutine is launched to remove the entry after the specified duration. The key-value pair is stored in the cache, and if a TTL is set, the entry is automatically deleted after the specified duration. The method returns nil, indicating a successful operation.

type Cacher

type Cacher interface {
	// Get returns the value associated with the specified key.
	// If the key is not found or an error occurs, an error object is returned.
	Get(key []byte) ([]byte, error)

	// Set adds the value associated with the specified key to the cache with the specified expiration time.
	// If the duration is zero, the cache is held indefinitely.
	Set(key []byte, value []byte, expiration time.Duration) error

	// Has checks whether the specified key exists in the cache.
	Has(key []byte) bool

	// Delete removes the specified key from the cache.
	// If the key is not found, an error object is returned.
	Delete(key []byte) error
}

https://github.com/mstgnz/ggcache Cacher is an interface used for performing caching operations. Applications can implement this interface to integrate different caching managers.

type Mail

type Mail struct {
	From        string
	Name        string
	Host        string
	Port        string
	User        string
	Pass        string
	Subject     string
	Content     string
	To          []string
	Cc          []string
	Bcc         []string
	Attachments map[string][]byte
}

https://github.com/mstgnz/gomail

func (*Mail) SendHTML

func (m *Mail) SendHTML() error

SendHTML sends the email with HTML content

func (*Mail) SendText

func (m *Mail) SendText() error

SendText sends the email with plain text content

func (*Mail) SetAttachment

func (m *Mail) SetAttachment(attachments map[string][]byte) *Mail

SetAttachment sets the email attachments

func (*Mail) SetBcc

func (m *Mail) SetBcc(bcc ...string) *Mail

SetBcc sets the email BCC recipients

func (*Mail) SetCc

func (m *Mail) SetCc(cc ...string) *Mail

SetCc sets the email CC recipients

func (*Mail) SetContent

func (m *Mail) SetContent(content string) *Mail

SetContent sets the email content

func (*Mail) SetFrom

func (m *Mail) SetFrom(from string) *Mail

SetFrom sets the sender's email address

func (*Mail) SetHost

func (m *Mail) SetHost(host string) *Mail

SetHost sets the SMTP server host

func (*Mail) SetName

func (m *Mail) SetName(name string) *Mail

SetName sets the sender's name

func (*Mail) SetPass

func (m *Mail) SetPass(pass string) *Mail

SetPass sets the SMTP server password

func (*Mail) SetPort

func (m *Mail) SetPort(port string) *Mail

SetPort sets the SMTP server port

func (*Mail) SetSubject

func (m *Mail) SetSubject(subject string) *Mail

SetSubject sets the email subject

func (*Mail) SetTo

func (m *Mail) SetTo(to ...string) *Mail

SetTo sets the email recipients

func (*Mail) SetUser

func (m *Mail) SetUser(user string) *Mail

SetUser sets the SMTP server username

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL