aop

package
v0.0.0-...-107dafa Latest Latest
Warning

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

Go to latest
Published: May 23, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package AOP contains the mechanism to bind a Cache Spot to a Go Function, starting from aop.CacheSpot struct.

Index

Constants

This section is empty.

Variables

View Source
var EMPTY_MAP = make(map[string]cache.CacheRegistry)
View Source
var RGX_FUNCNAME = regexp.MustCompile(`(.*\/)`)

regex that substitute the start of full function name

Functions

func GetFunctionName

func GetFunctionName(i interface{}) string

return function name

Types

type CacheSpot

type CacheSpot struct {
	CachedFunc        interface{}        //(required) empty function ref, that will contain cacheable function. Pass a nil reference
	HotFunc           interface{}        //(required) real hot function, that will have results cached
	CacheManager      cache.CacheManager //(required) cache manager for cache swaped function
	StoreOnly         bool               //(Optional) mark if cache manager can take cached values or just store results
	CacheIdPrefix     string             //(Optional) cache prefix for cache registries
	ValidateResults   TypeValidateResults
	SpecifyInputKeys  TypeSpecifyInputKeys
	SpecifyOutputKeys TypeSpecifyOutputKeys
	DefValsFunction   TypeCreateDefVals
	WaitingGroup      *sync.WaitGroup
	Ttl               float64
	CallContext       // will be mounted at start up nothing to do
}

template to make a cache spot function

func (CacheSpot) MustStartCache

func (cacheSpot CacheSpot) MustStartCache() CacheSpot

parse function signatures, validators, makes a swap function for reflection operations

func (CacheSpot) WaitAllParallelOps

func (cacheSpot CacheSpot) WaitAllParallelOps()

Wait for all store goroutines.

type CallContext

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

reflect objects need to reflect function call

type TypeCreateDefVals

type TypeCreateDefVals func(success bool, outTypes []reflect.Type) []reflect.Value

implemented by a function that needs to define default values to their returns determine default values for each return an string empty cache key (see method above) means that default value must be used DefaultValubleFunction

type TypeSpecifyInputKeys

type TypeSpecifyInputKeys func(in []reflect.Value, outTypes []reflect.Type) []string

To be implemented by a function that will need to define keys for cache SpecifyCacheKeys

type TypeSpecifyOutputKeys

type TypeSpecifyOutputKeys func(ins []reflect.Value, out []reflect.Value) ([]string, []reflect.Value)

contract to be implemented by a function that will need to define keys for cache determine cache key for each return value empty string cachekey means that default value must be used SpecifyOutKeys

type TypeValidateResults

type TypeValidateResults func(allIns []reflect.Value, allOuts []reflect.Value, cacheKey string, singleValueToCache interface{}) bool

Specialize validation results. Only valid results will be cached. called in one to any and many to any calls ValidateResults

Jump to

Keyboard shortcuts

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