redis

package
v0.0.0-...-d28c1d8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2016 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DailyBudgetScript

func DailyBudgetScript() string

KEYS[1] is the account key ARGV[1] is the daily budget ARGV[2] is the expiration time

func DebitIfNotZeroScript

func DebitIfNotZeroScript() string

KEYS[1] is the account key ARGV[1] is the amount to debit

func NewRedisBanker

func NewRedisBanker(da NoDbDataAccess) rtb.Banker

func NewRedisCampaign

func NewRedisCampaign(da NoDbDataAccess, id int64, accountKey string, targetSetKey string) rtb.Campaign

func NewRedisCampaignProvider

func NewRedisCampaignProvider(da NoDbDataAccess, banker rtb.Banker) rtb.CampaignProvider

func NewRedisPacer

func NewRedisPacer(cp rtb.CampaignProvider, da NoDbDataAccess, banker rtb.Banker, segment time.Duration) rtb.Pacer

func TargetKeysForTargets

func TargetKeysForTargets(prepend string, targets []rtb.Target) []string

Types

type NoDbDataAccess

type NoDbDataAccess interface {
	DeleteKeys(keys []string)
	HGetInt64(accountKey string, key string) int64
	HSetInt64(accountKey string, key string, val int64)
	GetInt64(accountKey string) (success bool, result int64)
	SetInt64(accountKey string, val int64)
	GetSetMembers(setKey string) []string
	AddMembersToSet(setKey string, members []interface{})
	AddMembersToSortedSets(keyValues map[string]SortedSetMember)
	SortedSetUnion(keys []string) []string
	DebitIfNotZero(accountKey string, amount int64, dailyBudget int64, dailyBudgetExpiration time.Time) (remainingDailyBudgetInMicroCents int64, err error)
	ExpireKey(key string, expirationTime time.Time)
	// Should only be used for testing
	GetKeys() []string
}

func NewRedisDataAccess

func NewRedisDataAccess(network string, addr string, appDomain string, poolSize int) NoDbDataAccess

type RedisBanker

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

func (*RedisBanker) DebitAccount

func (b *RedisBanker) DebitAccount(account int64, amount int64, dailyBudget int64, dailyBudgetExpiration time.Time) (remainingDailyBudgetInMicroCents int64, err error)

func (*RedisBanker) DeleteAccount

func (b *RedisBanker) DeleteAccount(account int64)

func (*RedisBanker) RemainingDailyBudgetInMicroCents

func (b *RedisBanker) RemainingDailyBudgetInMicroCents(account int64) int64

func (*RedisBanker) SetRemainingDailyBudgetInMicroCents

func (b *RedisBanker) SetRemainingDailyBudgetInMicroCents(account int64, amount int64, dailyBudgetExpiration time.Time)

type RedisCampaign

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

func (*RedisCampaign) BidCpmInMicroCents

func (c *RedisCampaign) BidCpmInMicroCents() int64

func (*RedisCampaign) DailyBudgetInMicroCents

func (c *RedisCampaign) DailyBudgetInMicroCents() int64

func (*RedisCampaign) Id

func (c *RedisCampaign) Id() int64

func (*RedisCampaign) Targets

func (c *RedisCampaign) Targets() *map[rtb.TargetType]string

type RedisCampaignProvider

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

func (*RedisCampaignProvider) CreateCampaign

func (cp *RedisCampaignProvider) CreateCampaign(campaignId int64, bidCpmInMicroCents int64, dailyBudgetInMicroCents int64, targets []rtb.Target) rtb.Campaign

func (*RedisCampaignProvider) DebitCampaign

func (cp *RedisCampaignProvider) DebitCampaign(campaignId int64, amountInMicroCents int64, dailyBudgetExpiration time.Time) (remainingDailyBudgetInMicroCents int64, err error)

func (*RedisCampaignProvider) ListCampaigns

func (cp *RedisCampaignProvider) ListCampaigns() []int64

func (*RedisCampaignProvider) ReadByTargeting

func (cp *RedisCampaignProvider) ReadByTargeting(bidFloorInMicroCents int64, targets []rtb.Target) []rtb.Campaign

func (*RedisCampaignProvider) ReadCampaign

func (cp *RedisCampaignProvider) ReadCampaign(campaignId int64) rtb.Campaign

type RedisDataAccess

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

func (*RedisDataAccess) AddMembersToSet

func (da *RedisDataAccess) AddMembersToSet(setKey string, members []interface{})

func (*RedisDataAccess) AddMembersToSortedSets

func (da *RedisDataAccess) AddMembersToSortedSets(keyValues map[string]SortedSetMember)

func (*RedisDataAccess) DebitIfNotZero

func (da *RedisDataAccess) DebitIfNotZero(accountKey string, amount int64, dailyBudget int64, dailyBudgetExpiration time.Time) (remainingDailyBudgetInMicroCents int64, err error)

func (*RedisDataAccess) DeleteKeys

func (da *RedisDataAccess) DeleteKeys(keys []string)

func (*RedisDataAccess) ExpireKey

func (da *RedisDataAccess) ExpireKey(key string, expirationTime time.Time)

func (*RedisDataAccess) GetInt64

func (da *RedisDataAccess) GetInt64(accountKey string) (success bool, result int64)

func (*RedisDataAccess) GetKeys

func (da *RedisDataAccess) GetKeys() []string

Should only be used for testing

func (*RedisDataAccess) GetSetMembers

func (da *RedisDataAccess) GetSetMembers(setKey string) []string

func (*RedisDataAccess) HGetInt64

func (da *RedisDataAccess) HGetInt64(accountKey string, key string) int64

func (*RedisDataAccess) HSetInt64

func (da *RedisDataAccess) HSetInt64(accountKey string, key string, val int64)

func (*RedisDataAccess) SetInt64

func (da *RedisDataAccess) SetInt64(accountKey string, val int64)

func (*RedisDataAccess) SortedSetUnion

func (da *RedisDataAccess) SortedSetUnion(keys []string) []string

type RedisPacer

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

Implements a simple time segmented pacer. Dividing the daily budget into time segments based on the segment duration provided

func (*RedisPacer) CanBid

func (p *RedisPacer) CanBid(campaign rtb.Campaign) bool

func (*RedisPacer) Segment

func (p *RedisPacer) Segment() time.Duration

type SortedSetMember

type SortedSetMember struct {
	Score  int64
	Member interface{}
}

Jump to

Keyboard shortcuts

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