backend

package
v0.0.0-...-8d8ec1c Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package backend - Rate Limit 기능을 제공하는 저장소 패키지

Package backend - 문자열 Hash 처리 패키지

Package backend - Rate Limit 정보를 메모리에 관리하는 패키지

Package backend - MemoeryBackend에 대한 sharding 처리 패키지

Index

Constants

This section is empty.

Variables

View Source
var (
	// DataTTL - 데이터 유지 시간
	DataTTL = 10 * time.Minute
)

Functions

func PseudoFNV64a

func PseudoFNV64a(s string) uint64

PseudoFNV64a - 지정한 문자열을 Hash 처리

Types

type Hasher

type Hasher func(string) uint64

Hasher - 지정된 문자열을 Hash 처리하는 함수 형식

type IBackend

type IBackend interface {
	Load(string, func() interface{}) interface{}
	Store(string, interface{}) error
}

IBackend - 데이터 저장소 인터페이스

type MemoryBackend

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

MemoryBackend - sync.Map Wrapping을 사용하는 Memory Backend 구조

func NewMemoryBackend

func NewMemoryBackend(ctx context.Context, ttl time.Duration) *MemoryBackend

NewMemoryBackend - 지정된 시간동안 유지되는 Memory Backend Store 생성

func (*MemoryBackend) Load

func (mb *MemoryBackend) Load(key string, f func() interface{}) interface{}

Load - 지정한 키에 해당하는 정보를 MemoryBackend 에서 로드

func (*MemoryBackend) Store

func (mb *MemoryBackend) Store(key string, v interface{}) error

Store - 지정한 키에 해당하는 정보를 MemoryBackend에 저장

type ShardedMemoryBackend

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

ShardedMemoryBackend - Mutex 경합을 피해 데이터를 Sharding하는 Memory Backend 구조

func DefaultShardedMemoryBackend

func DefaultShardedMemoryBackend(ctx context.Context) *ShardedMemoryBackend

DefaultShardedMemoryBackend - 기본 Shard 갯수 (2048)를 기반으로 분산하는 MemoryBackend 생성

func NewShardedMemoryBackend

func NewShardedMemoryBackend(ctx context.Context, shards uint64, ttl time.Duration, h Hasher) *ShardedMemoryBackend

NewShardedMemoryBackend - 지정된 shard 수에 맞는 Memory기반 ShardedBackend 생성

func (*ShardedMemoryBackend) Load

func (smb *ShardedMemoryBackend) Load(key string, f func() interface{}) interface{}

Load - 지정한 키에 해당하는 정보를 ShardedMemoryBackend에서 로드

func (*ShardedMemoryBackend) Store

func (smb *ShardedMemoryBackend) Store(key string, v interface{}) error

Store - 지정한 키에 해당하는 정보를 ShardedMemoryBackend로 저장

Jump to

Keyboard shortcuts

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