caches

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoginRate = rate.Limit(2.0)

LoginRate limit to 2 login attempts per second.

Functions

func API

func API(ctx context.Context) *ristretto.Cache

func AllowAPI

func AllowAPI(ctx context.Context, aid uint64, by rate.Limit, burst int) bool

func AllowRemoteIPLogin

func AllowRemoteIPLogin(ctx context.Context, ip string) bool

func AllowSite

func AllowSite(ctx context.Context, domain string) (uid, sid uint64, ok bool)

func AllowUseIDToLogin

func AllowUseIDToLogin(ctx context.Context, uid uint64) bool

func Close

func Close(ctx context.Context) error

func IP

func IP(ctx context.Context) *ristretto.Cache

func Open

func Open(ctx context.Context, onSession func(context.Context, *entry.Entry)) (context.Context, error)

func Session

func Session(ctx context.Context) *ristretto.Cache

func SetSite

func SetSite(ctx context.Context, ttl time.Duration) func(*models.CachedSite)

func Site

func Site(ctx context.Context) *ristretto.Cache

func User

func User(ctx context.Context) *ristretto.Cache

Types

type SiteRate

type SiteRate struct {
	SID        uint64
	UID        uint64
	HasStarted atomic.Bool
	Rate       *rate.Limiter
}

func (*SiteRate) Allow

func (s *SiteRate) Allow(ctx context.Context) (uint64, uint64, bool)

Jump to

Keyboard shortcuts

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