groupscache

package
v1.6.1-0...-105477e Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TTL = 60 * 60 * 24 // 1 day

TTL is time to live for group in cache

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	File string
	// contains filtered or unexported fields
}

Cache provides cache for groups

func New

func New(file string, api2 api.Api) *Cache

New creates new cache instance

func (*Cache) AddGroup

func (c *Cache) AddGroup(group Group) error

AddGroup adds group to cache

func (*Cache) AddGroups

func (c *Cache) AddGroups(groups []Group) error

AddGroups adds groups to cache

func (*Cache) GetGroupById

func (c *Cache) GetGroupById(id int) (*Group, error)

GetGroupById returns group by id

func (*Cache) GetGroupByName

func (c *Cache) GetGroupByName(name string) (*Group, error)

GetGroupByName returns group by name. Not case sensitive

func (*Cache) Load

func (c *Cache) Load() error

Load cache from csv file

File format:

id;name;course;faculty_id;updated

func (*Cache) Save

func (c *Cache) Save() error

Save cache to csv file

type Group

type Group struct {
	Id        int
	Name      string
	Course    int
	FacultyId int
	Updated   int64
}

Group represents group

Jump to

Keyboard shortcuts

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