Documentation ¶
Index ¶
- Constants
- Variables
- func AddScopedICache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
- func AddScopedICacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddScopedICacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, ...)
- func AddScopedICacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, ...)
- func AddScopedIMemoryCache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
- func AddScopedIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddScopedIMemoryCacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, ...)
- func AddScopedIMemoryCacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, ...)
- func AddSingletonICache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
- func AddSingletonICacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonICacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonICacheByObj(builder *di.Builder, obj interface{}, implementedTypes ...reflect.Type)
- func AddSingletonICacheByObjWithMetadata(builder *di.Builder, obj interface{}, metaData map[string]interface{}, ...)
- func AddSingletonICacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, ...)
- func AddSingletonIMemoryCache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
- func AddSingletonIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonIMemoryCacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonIMemoryCacheByObj(builder *di.Builder, obj interface{}, implementedTypes ...reflect.Type)
- func AddSingletonIMemoryCacheByObjWithMetadata(builder *di.Builder, obj interface{}, metaData map[string]interface{}, ...)
- func AddSingletonIMemoryCacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, ...)
- func AddTransientICache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
- func AddTransientICacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddTransientICacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, ...)
- func AddTransientICacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, ...)
- func AddTransientIMemoryCache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
- func AddTransientIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddTransientIMemoryCacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, ...)
- func AddTransientIMemoryCacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, ...)
- func GetICacheDefinition(ctn di.Container) *di.Def
- func GetICacheDefinitions(ctn di.Container) []*di.Def
- func GetIMemoryCacheDefinition(ctn di.Container) *di.Def
- func GetIMemoryCacheDefinitions(ctn di.Container) []*di.Def
- func RemoveAllICache(builder *di.Builder)
- func RemoveAllIMemoryCache(builder *di.Builder)
- type ICache
- type IMemoryCache
Constants ¶
const ( // Forever Always exist Forever = 0 // Seconds1 1 second Seconds1 = time.Second // Seconds2 2 second Seconds2 = 2 * time.Second // Seconds3 3 second Seconds3 = 3 * time.Second // Seconds5 5 second Seconds5 = 5 * time.Second // Seconds6 6 second Seconds6 = 6 * time.Second // Seconds7 7 second Seconds7 = 7 * time.Second // Seconds8 8 second Seconds8 = 8 * time.Second // Seconds9 9 second Seconds9 = 9 * time.Second // Seconds10 10 second Seconds10 = 10 * time.Second // Seconds15 15 second Seconds15 = 15 * time.Second // Seconds20 20 second Seconds20 = 20 * time.Second // Seconds30 30 second Seconds30 = 30 * time.Second // OneMinutes 1 minutes OneMinutes = 60 * time.Second // TwoMinutes 2 minutes TwoMinutes = 120 * time.Second // ThreeMinutes 3 minutes ThreeMinutes = 180 * time.Second // FiveMinutes 5 minutes FiveMinutes = 300 * time.Second // TenMinutes 10 minutes TenMinutes = 600 * time.Second // FifteenMinutes 15 minutes FifteenMinutes = 900 * time.Second // HalfHour half an hour HalfHour = 1800 * time.Second // OneHour 1 hour OneHour = 3600 * time.Second // TwoHour 2 hours TwoHour = 7200 * time.Second // ThreeHour 3 hours ThreeHour = 10800 * time.Second // HalfDay 12 hours(half of the day) HalfDay = 43200 * time.Second // OneDay 24 hours(1 day) OneDay = 86400 * time.Second // TwoDay 2 day TwoDay = 172800 * time.Second // ThreeDay 3 day ThreeDay = 259200 * time.Second // OneWeek 7 day(one week) OneWeek = 604800 * time.Second )
some generic expire time define.
Variables ¶
var ReflectTypeICache = di.GetInterfaceReflectType((*ICache)(nil))
ReflectTypeICache used when your service claims to implement ICache
var ReflectTypeIMemoryCache = di.GetInterfaceReflectType((*IMemoryCache)(nil))
ReflectTypeIMemoryCache used when your service claims to implement IMemoryCache
Functions ¶
func AddScopedICache ¶
AddScopedICache adds a type that implements ICache
func AddScopedICacheByFunc ¶
func AddScopedICacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), implementedTypes ...reflect.Type)
AddScopedICacheByFunc adds a type by a custom func
func AddScopedICacheByFuncWithMetadata ¶ added in v0.1.217
func AddScopedICacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddScopedICacheByFuncWithMetadata adds a type by a custom func
func AddScopedICacheWithMetadata ¶ added in v0.1.217
func AddScopedICacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddScopedICacheWithMetadata adds a type that implements ICache
func AddScopedIMemoryCache ¶
func AddScopedIMemoryCache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
AddScopedIMemoryCache adds a type that implements IMemoryCache
func AddScopedIMemoryCacheByFunc ¶
func AddScopedIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), implementedTypes ...reflect.Type)
AddScopedIMemoryCacheByFunc adds a type by a custom func
func AddScopedIMemoryCacheByFuncWithMetadata ¶ added in v0.1.217
func AddScopedIMemoryCacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddScopedIMemoryCacheByFuncWithMetadata adds a type by a custom func
func AddScopedIMemoryCacheWithMetadata ¶ added in v0.1.217
func AddScopedIMemoryCacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddScopedIMemoryCacheWithMetadata adds a type that implements IMemoryCache
func AddSingletonICache ¶
func AddSingletonICache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
AddSingletonICache adds a type that implements ICache
func AddSingletonICacheByFunc ¶
func AddSingletonICacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), implementedTypes ...reflect.Type)
AddSingletonICacheByFunc adds a type by a custom func
func AddSingletonICacheByFuncWithMetadata ¶ added in v0.1.217
func AddSingletonICacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddSingletonICacheByFuncWithMetadata adds a type by a custom func
func AddSingletonICacheByObj ¶
func AddSingletonICacheByObj(builder *di.Builder, obj interface{}, implementedTypes ...reflect.Type)
AddSingletonICacheByObj adds a prebuilt obj
func AddSingletonICacheByObjWithMetadata ¶ added in v0.1.217
func AddSingletonICacheByObjWithMetadata(builder *di.Builder, obj interface{}, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddSingletonICacheByObjWithMetadata adds a prebuilt obj
func AddSingletonICacheWithMetadata ¶ added in v0.1.217
func AddSingletonICacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddSingletonICacheWithMetadata adds a type that implements ICache
func AddSingletonIMemoryCache ¶
func AddSingletonIMemoryCache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
AddSingletonIMemoryCache adds a type that implements IMemoryCache
func AddSingletonIMemoryCacheByFunc ¶
func AddSingletonIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), implementedTypes ...reflect.Type)
AddSingletonIMemoryCacheByFunc adds a type by a custom func
func AddSingletonIMemoryCacheByFuncWithMetadata ¶ added in v0.1.217
func AddSingletonIMemoryCacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddSingletonIMemoryCacheByFuncWithMetadata adds a type by a custom func
func AddSingletonIMemoryCacheByObj ¶
func AddSingletonIMemoryCacheByObj(builder *di.Builder, obj interface{}, implementedTypes ...reflect.Type)
AddSingletonIMemoryCacheByObj adds a prebuilt obj
func AddSingletonIMemoryCacheByObjWithMetadata ¶ added in v0.1.217
func AddSingletonIMemoryCacheByObjWithMetadata(builder *di.Builder, obj interface{}, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddSingletonIMemoryCacheByObjWithMetadata adds a prebuilt obj
func AddSingletonIMemoryCacheWithMetadata ¶ added in v0.1.217
func AddSingletonIMemoryCacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddSingletonIMemoryCacheWithMetadata adds a type that implements IMemoryCache
func AddTransientICache ¶
func AddTransientICache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
AddTransientICache adds a type that implements ICache
func AddTransientICacheByFunc ¶
func AddTransientICacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), implementedTypes ...reflect.Type)
AddTransientICacheByFunc adds a type by a custom func
func AddTransientICacheByFuncWithMetadata ¶ added in v0.1.217
func AddTransientICacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddTransientICacheByFuncWithMetadata adds a type by a custom func
func AddTransientICacheWithMetadata ¶ added in v0.1.217
func AddTransientICacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddTransientICacheWithMetadata adds a type that implements ICache
func AddTransientIMemoryCache ¶
func AddTransientIMemoryCache(builder *di.Builder, implType reflect.Type, implementedTypes ...reflect.Type)
AddTransientIMemoryCache adds a type that implements IMemoryCache
func AddTransientIMemoryCacheByFunc ¶
func AddTransientIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), implementedTypes ...reflect.Type)
AddTransientIMemoryCacheByFunc adds a type by a custom func
func AddTransientIMemoryCacheByFuncWithMetadata ¶ added in v0.1.217
func AddTransientIMemoryCacheByFuncWithMetadata(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error), metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddTransientIMemoryCacheByFuncWithMetadata adds a type by a custom func
func AddTransientIMemoryCacheWithMetadata ¶ added in v0.1.217
func AddTransientIMemoryCacheWithMetadata(builder *di.Builder, implType reflect.Type, metaData map[string]interface{}, implementedTypes ...reflect.Type)
AddTransientIMemoryCacheWithMetadata adds a type that implements IMemoryCache
func GetICacheDefinition ¶ added in v0.1.217
GetICacheDefinition returns that last definition registered that this container can provide
func GetICacheDefinitions ¶ added in v0.1.217
GetICacheDefinitions returns all definitions that this container can provide
func GetIMemoryCacheDefinition ¶ added in v0.1.217
GetIMemoryCacheDefinition returns that last definition registered that this container can provide
func GetIMemoryCacheDefinitions ¶ added in v0.1.217
GetIMemoryCacheDefinitions returns all definitions that this container can provide
func RemoveAllICache ¶
RemoveAllICache removes all ICache from the DI
func RemoveAllIMemoryCache ¶
RemoveAllIMemoryCache removes all IMemoryCache from the DI
Types ¶
type ICache ¶
type ICache interface { ttlcache.SimpleCache GetOrInsert(k string, adder func() (interface{}, time.Duration, error)) interface{} }
ICache interface
func GetICacheFromContainer ¶
GetICacheFromContainer alternative to SafeGetICacheFromContainer but panics of object is not present
func GetManyICacheFromContainer ¶ added in v0.1.178
GetManyICacheFromContainer alternative to SafeGetManyICacheFromContainer but panics of object is not present
func SafeGetICacheFromContainer ¶
SafeGetICacheFromContainer trys to get the object by type, will not panic, returns nil and error
type IMemoryCache ¶
type IMemoryCache interface { ICache }
IMemoryCache interface
func GetIMemoryCacheFromContainer ¶
func GetIMemoryCacheFromContainer(ctn di.Container) IMemoryCache
GetIMemoryCacheFromContainer alternative to SafeGetIMemoryCacheFromContainer but panics of object is not present
func GetManyIMemoryCacheFromContainer ¶ added in v0.1.178
func GetManyIMemoryCacheFromContainer(ctn di.Container) []IMemoryCache
GetManyIMemoryCacheFromContainer alternative to SafeGetManyIMemoryCacheFromContainer but panics of object is not present
func SafeGetIMemoryCacheFromContainer ¶
func SafeGetIMemoryCacheFromContainer(ctn di.Container) (IMemoryCache, error)
SafeGetIMemoryCacheFromContainer trys to get the object by type, will not panic, returns nil and error
func SafeGetManyIMemoryCacheFromContainer ¶ added in v0.1.178
func SafeGetManyIMemoryCacheFromContainer(ctn di.Container) ([]IMemoryCache, error)
SafeGetManyIMemoryCacheFromContainer trys to get the object by type, will not panic, returns nil and error