use of com.pratilipi.data.Memcache in project pratilipi by Pratilipi.
the class DataStoreUtil method main.
public static void main(String... args) throws IOException, UnexpectedServerException, InterruptedException, ParseException {
RemoteApiOptions options = new RemoteApiOptions().server("m.gamma.pratilipi.com", 80).useServiceAccountCredential("prod-pratilipi@appspot.gserviceaccount.com", "PrivateKey.p12").remoteApiPath("/remote_api");
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
ObjectifyService.begin();
Memcache memcache = DataAccessorFactory.getL2CacheAccessor();
GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
BlobAccessor blobAccessor = DataAccessorFactory.getBlobAccessor();
DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
// START
// END
installer.uninstall();
}
use of com.pratilipi.data.Memcache in project pratilipi by Pratilipi.
the class AuthorDataUtil method _getRecommendAuthorGlobalList.
private static List<Long> _getRecommendAuthorGlobalList(Language language) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
Memcache memcache = DataAccessorFactory.getL2CacheAccessor();
String memcacheId = "AuthorDataUtil.RecommendAuthorGlobalList-" + language.getCode();
List<Long> authorList = memcache.get(memcacheId);
if (authorList != null)
return authorList;
Long minReadCount;
switch(language) {
case BENGALI:
minReadCount = 3000L;
break;
case GUJARATI:
minReadCount = 2000L;
break;
case HINDI:
minReadCount = 7500L;
break;
case KANNADA:
minReadCount = 200L;
break;
case MALAYALAM:
minReadCount = 4000L;
break;
case MARATHI:
minReadCount = 2000L;
break;
case TAMIL:
minReadCount = 2200L;
break;
case TELUGU:
minReadCount = 500L;
break;
default:
minReadCount = 2000L;
}
authorList = dataAccessor.getAuthorIdListWithMaxReadCount(language, minReadCount, 1000);
// Algorithm - Shuffling the list in order
int[] order = { 1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 21, 20, 22, 24, 23 };
int orderSize = order.length;
ArrayList<Long> resultList = new ArrayList<>(authorList.size());
int chunkSize = authorList.size() / orderSize;
for (int i = 0; i < order.length; i++) {
int beginIndex = (order[i] - 1) * chunkSize;
List<Long> subList = authorList.subList(beginIndex, beginIndex + chunkSize);
Collections.shuffle(subList);
resultList.addAll(subList);
}
resultList.addAll(authorList.subList(authorList.size() - (authorList.size() % orderSize), authorList.size()));
// Caching the result in memcache for 3 hours
memcache.put(memcacheId, resultList, 180);
return resultList;
}
Aggregations