// NewItem will register new StorageItem and return it
NewItem will register new StorageItem and return it
// NewItem will register new StorageItem and return it
func (s *Storage) NewItem(level int, lang string, ttl int64) *StorageItem {
	s.mu.Lock()
	defer s.mu.Unlock()
	expireTime := time.Now()
	expireTime = expireTime.Add(time.Second * time.Duration(ttl))
	id := GenerateID()
	value := GenerateProblem(level)
	intlValue := ConvertUInt64ToString(value)
	if lang == "fa" {
		intlValue = message.NewPrinter(language.Persian).Sprintf("%v", number.Decimal(value, number.NoSeparator()))
	} else if lang == "ar" {
		intlValue = message.NewPrinter(language.Arabic).Sprintf("%v", number.Decimal(value, number.NoSeparator()))
	}
	item := StorageItem{ID: id, Value: value, Language: lang, IntlValue: intlValue, Level: level, Expire: expireTime}
	s.expire[id] = expireTime.Unix()
	s.values[id] = value
	return &item
}
func ( s * Storage ) NewItem ( level int , lang string , ttl int64 ) * StorageItem { s . mu . Lock ( ) defer s . mu . Unlock ( ) expireTime := time . Now ( ) expireTime = expireTime . Add ( time . Second * time . Duration ( ttl ) ) id := GenerateID ( ) value := GenerateProblem ( level ) intlValue := ConvertUInt64ToString ( value ) if lang == " " { intlValue = message . NewPrinter ( language . Persian ) . Sprintf ( " " , number . Decimal ( value , number . NoSeparator ( ) ) ) } else if lang == " " { intlValue = message . NewPrinter ( language . Arabic ) . Sprintf ( " " , number . Decimal ( value , number . NoSeparator ( ) ) ) } item := StorageItem { ID : id , Value : value , Language : lang , IntlValue : intlValue , Level : level , Expire : expireTime } s . expire [ id ] = expireTime . Unix ( ) s . values [ id ] = value return & item }
NewItem will register new StorageItem and return it
NewItem will register new StorageItem and return it