예제 #1
0
// PurgeCache removes an item from the cache
func PurgeCache(itemTypeID int64, itemID int64) {
	switch itemTypeID {

	case h.ItemTypes[h.ItemTypeAlbum]:

	case h.ItemTypes[h.ItemTypeArticle]:

	case h.ItemTypes[h.ItemTypeAttendee]:
		for _, mcKeyFmt := range mcAttendeeKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeClassified]:

	case h.ItemTypes[h.ItemTypeComment]:
		for _, mcKeyFmt := range mcCommentKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeConversation]:
		for _, mcKeyFmt := range mcConversationKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeEvent]:
		for _, mcKeyFmt := range mcEventKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeHuddle]:
		for _, mcKeyFmt := range mcHuddleKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeMicrocosm]:
		for _, mcKeyFmt := range mcMicrocosmKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypePoll]:
		for _, mcKeyFmt := range mcPollKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeProfile]:
		for _, mcKeyFmt := range mcProfileKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeQuestion]:

	case h.ItemTypes[h.ItemTypeRole]:

		// Need to flush the database cache if we're flushing everything to
		// do with the role
		tx, err := h.GetTransaction()
		if err != nil {
			glog.Errorf("+%v", err)
			return
		}
		defer tx.Rollback()

		_, err = FlushRoleMembersCacheByRoleID(tx, itemID)
		if err != nil {
			glog.Errorf("+%v", err)
			return
		}

		err = tx.Commit()
		if err != nil {
			glog.Errorf("+%v", err)
			return
		}

		for _, mcKeyFmt := range mcRoleKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeSite]:
		for _, mcKeyFmt := range mcSiteKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeUpdate]:
		for _, mcKeyFmt := range mcUpdateKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	case h.ItemTypes[h.ItemTypeWatcher]:
		for _, mcKeyFmt := range mcWatcherKeys {
			c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
		}

	default:
	}
}
예제 #2
0
// PurgeCacheByScope removes part of an item from the cache
func PurgeCacheByScope(scope int, itemTypeID int64, itemID int64) {
	switch itemTypeID {

	case h.ItemTypes[h.ItemTypeAlbum]:

	case h.ItemTypes[h.ItemTypeArticle]:

	case h.ItemTypes[h.ItemTypeAttendee]:
		for mcKey, mcKeyFmt := range mcAttendeeKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeClassified]:

	case h.ItemTypes[h.ItemTypeComment]:
		for mcKey, mcKeyFmt := range mcCommentKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeConversation]:
		for mcKey, mcKeyFmt := range mcConversationKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeEvent]:
		for mcKey, mcKeyFmt := range mcEventKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeHuddle]:
		for mcKey, mcKeyFmt := range mcHuddleKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeMicrocosm]:
		for mcKey, mcKeyFmt := range mcMicrocosmKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypePoll]:
		for mcKey, mcKeyFmt := range mcPollKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeProfile]:
		for mcKey, mcKeyFmt := range mcProfileKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeQuestion]:

	case h.ItemTypes[h.ItemTypeRole]:
		for mcKey, mcKeyFmt := range mcRoleKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	case h.ItemTypes[h.ItemTypeSite]:
		for mcKey, mcKeyFmt := range mcSiteKeys {
			if mcKey == scope {
				c.Delete(fmt.Sprintf(mcKeyFmt, itemID))
			}
		}

	default:
	}
}