Example #1
0
  /**
   * Delete
   *
   * @param model
   * @return
   */
  public static void delete(UserModel userModel) {

    // ユーザーのすべてのDateModelを取得
    List<DateModel> dateModelList = userModel.getDateModelListRef().getModelList();

    for (DateModel dateModel : dateModelList) {
      // DateModelに紐づくつべてのActivityModel を取得
      List<ActivityModel> activityModelList = dateModel.getActivityModelListRef().getModelList();

      for (ActivityModel activityModel : activityModelList) {
        // アクティビティの削除
        ActivityService.delete(userModel, activityModel);
      }

      // DateModelの削除
      DateService.delete(userModel, dateModel);
    }

    // URLリストの削除
    UserUrlsService.deleteAll(userModel);

    userModelDao.delete(userModel.getKey());

    // 自信のキャッシュをクリア
    Memcache.delete(userModel.getKey().toString());

    // ユーザーカウントのキャッシュクリア
    clearUserCountAndListMemcache();
    // グループのキャッシュをクリア
    clearGroupUserListMemcache(userModel.getGroup());
  }
Example #2
0
  /**
   * すべてのユーザーリストを取得
   *
   * @return
   */
  public static List<UserModel> getAllUserList() {
    List<UserModel> userList = Memcache.get(ALL_USER_LIST);
    if (Utils.isNotEmpty(userList)) return userList;

    userList = userModelDao.getAllUserList();
    if (Utils.isNotEmpty(userList)) Memcache.put(ALL_USER_LIST, userList);

    return userList;
  }
Example #3
0
  /**
   * グループのユーザーリストを取得
   *
   * @param groupId
   * @return
   */
  public static List<UserModel> getGroupUserList(int groupId) {

    List<UserModel> userList = Memcache.get(getGroupUserListMemcache(groupId));
    if (Utils.isNotEmpty(userList)) return userList;

    userList = userModelDao.getGroupUserList(groupId);
    if (Utils.isNotEmpty(userList)) Memcache.put(getGroupUserListMemcache(groupId), userList);

    return userList == null ? new ArrayList<UserModel>() : userList;
  }
Example #4
0
  /**
   * ユーザーカウントの取得
   *
   * @return
   */
  public static int getUserCount() {

    int serviceUserCount =
        (Integer) (Memcache.get(SERVICE_USER_COUNT) == null ? 0 : Memcache.get(SERVICE_USER_COUNT));
    if (serviceUserCount > 0) return serviceUserCount;

    serviceUserCount = userModelDao.getUserCount();
    if (serviceUserCount > 0) Memcache.put(SERVICE_USER_COUNT, serviceUserCount);

    return serviceUserCount;
  }
Example #5
0
  /**
   * ユーザーの取得
   *
   * @param email
   * @return
   */
  public static UserModel getOrNull(String userID) {

    Key key = createKey(userID);
    UserModel model = Memcache.get(key.toString());
    if (model != null) return model;

    model = userModelDao.getOrNull(key);
    if (model != null) Memcache.put(model.getKey().toString(), model);

    return model;
  }
Example #6
0
  /**
   * PUT
   *
   * @param model
   * @return
   */
  public static UserModel put(UserModel model) {
    // 永久化
    userModelDao.put(model);

    // 自信のキャッシュをクリア
    Memcache.delete(model.getKey().toString());

    // グループのキャッシュをクリア
    clearGroupUserListMemcache(model.getGroup());

    return model;
  }
Example #7
0
  /**
   * ユーザーリストを取得
   *
   * @return
   */
  public static S3QueryResultList<UserModel> getUserList(String cursor) {

    S3QueryResultList<UserModel> list = null;

    // 最初のページをキャッシュする
    if (StringUtil.isEmpty(cursor)) {
      // Memcache に存在した場合はMemcache内のmodelを返す
      list = Memcache.get(USER_LIST_FIRST_30);
      if (Utils.isNotEmpty(list)) return list;

      // DBから取得し、存在した場合はMemcacheに入れる
      list = userModelDao.getUserList(Constants.SERVICE_USER_LIST_LIMIT_NUM);
      if (Utils.isNotEmpty(list)) Memcache.put(USER_LIST_FIRST_30, list);

    } else {
      list = userModelDao.getUserList(Constants.SERVICE_USER_LIST_LIMIT_NUM, cursor);
    }

    return list == null
        ? new S3QueryResultList<UserModel>(new ArrayList<UserModel>(), null, null, null, false)
        : list;
  }