CacheSv1.HasGroup API

This commit is contained in:
DanB
2018-03-09 19:29:19 +01:00
parent 0a1626cd4f
commit 63dbd3e714
2 changed files with 18 additions and 3 deletions

View File

@@ -75,8 +75,14 @@ func (chSv1 *CacheSv1) PrecacheStatus(cacheIDs []string, rply *map[string]string
return chSv1.cacheS.V1PrecacheStatus(cacheIDs, rply)
}
// HasGroup checks existence of a group in cache
func (chSv1 *CacheSv1) HasGroup(args *engine.ArgsGetGroup,
rply *bool) (err error) {
return chSv1.cacheS.V1HasGroup(args, rply)
}
// GetGroupItemIDs returns a list of itemIDs in a cache group
func (chSv1 *CacheSv1) GetGroupItemIDs(args *engine.ArgsGetGroupItems,
func (chSv1 *CacheSv1) GetGroupItemIDs(args *engine.ArgsGetGroup,
rply *[]string) (err error) {
return chSv1.cacheS.V1GetGroupItemIDs(args, rply)
}

View File

@@ -191,13 +191,22 @@ func (chS *CacheS) V1PrecacheStatus(cacheIDs []string, rply *map[string]string)
return
}
type ArgsGetGroupItems struct {
type ArgsGetGroup struct {
CacheID string
GroupID string
}
func (chS *CacheS) V1GetGroupItemIDs(args *ArgsGetGroupItems,
func (chS *CacheS) V1HasGroup(args *ArgsGetGroup,
rply *bool) (err error) {
*rply = Cache.HasGroup(args.CacheID, args.GroupID)
return
}
func (chS *CacheS) V1GetGroupItemIDs(args *ArgsGetGroup,
rply *[]string) (err error) {
if has := Cache.HasGroup(args.CacheID, args.GroupID); !has {
return utils.ErrNotFound
}
*rply = Cache.GetGroupItemIDs(args.CacheID, args.GroupID)
return
}