def cron(request): """ Preload memcache with some JSON requests. """ version = settings.JSON_VERSION left = random_prefix(length_choices=[1, 2, 3]) right = '' lines = [] for length in range(max(2, len(left)) + 1, MAX_NAME_LENGTH + 1): memcache_key = 'json%d,%s,%s,%d' % (version, left, right, length) json = generate_json(left, right, length) memcache.set(memcache_key, json, MEMCACHE_TIMEOUT) lines.append(json[:120] + '...' if len(json) > 120 else json) return render_to_response(request, 'search/cron.html', locals())
def update_random(options): position = random.choice(('left', 'right')) keyword = random_prefix(position, length_choices=[2, 3, 4]) for length in range(max(options.min, len(keyword) + 1), options.max + 1): update_best_names(position, keyword, length, options)