Documentation ¶
Index ¶
- Constants
- Variables
- func AddScopedICache(builder *di.Builder, implType reflect.Type)
- func AddScopedICacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddScopedIMemoryCache(builder *di.Builder, implType reflect.Type)
- func AddScopedIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonICache(builder *di.Builder, implType reflect.Type)
- func AddSingletonICacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonICacheByObj(builder *di.Builder, obj interface{})
- func AddSingletonIMemoryCache(builder *di.Builder, implType reflect.Type)
- func AddSingletonIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddSingletonIMemoryCacheByObj(builder *di.Builder, obj interface{})
- func AddTransientICache(builder *di.Builder, implType reflect.Type)
- func AddTransientICacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- func AddTransientIMemoryCache(builder *di.Builder, implType reflect.Type)
- func AddTransientIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, ...)
- 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))
AddScopedICacheByFunc adds a type by a custom func
func AddScopedIMemoryCache ¶
AddScopedIMemoryCache adds a type that implements IMemoryCache
func AddScopedIMemoryCacheByFunc ¶
func AddScopedIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error))
AddScopedIMemoryCacheByFunc adds a type by a custom func
func AddSingletonICache ¶
AddSingletonICache adds a type that implements ICache
func AddSingletonICacheByFunc ¶
func AddSingletonICacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error))
AddSingletonICacheByFunc adds a type by a custom func
func AddSingletonICacheByObj ¶
AddSingletonICacheByObj adds a prebuilt obj
func AddSingletonIMemoryCache ¶
AddSingletonIMemoryCache adds a type that implements IMemoryCache
func AddSingletonIMemoryCacheByFunc ¶
func AddSingletonIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error))
AddSingletonIMemoryCacheByFunc adds a type by a custom func
func AddSingletonIMemoryCacheByObj ¶
AddSingletonIMemoryCacheByObj adds a prebuilt obj
func AddTransientICache ¶
AddTransientICache adds a type that implements ICache
func AddTransientICacheByFunc ¶
func AddTransientICacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error))
AddTransientICacheByFunc adds a type by a custom func
func AddTransientIMemoryCache ¶
AddTransientIMemoryCache adds a type that implements IMemoryCache
func AddTransientIMemoryCacheByFunc ¶
func AddTransientIMemoryCacheByFunc(builder *di.Builder, implType reflect.Type, build func(ctn di.Container) (interface{}, error))
AddTransientIMemoryCacheByFunc adds a type by a custom func
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
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 SafeGetIMemoryCacheFromContainer ¶
func SafeGetIMemoryCacheFromContainer(ctn di.Container) (IMemoryCache, error)
SafeGetIMemoryCacheFromContainer trys to get the object by type, will not panic, returns nil and error