Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Redis cache with drop downs #941


User avatar
0
sampath created

Hi,

My SPA app's pop up is having around 30 drop downs.All the data are retrieving through the ajax calls as shown below. This pop up is very slow due to so many drop downs.Hence I would like to use redis cache with it.Is asp.net zero support redis cache out of the box (ver. v1.7.1.1 [20160328]) ? If I need to use redis cache for the above scenario can you suggest me the best way for doing it ? Do I need to run back end task to fill those data to the redis cache or which way is it good ? Thanks.

JS

vm.getAllCities = function () {
                cityService.getAllCitiesAsync().success(function (result) {
                    vm.cities = result.items;
                });
            };

            vm.getAllCities();

Html

<div class="col-xs-3">
                <div class="form-group">
                    <label class="control-label">@L("City")</label>
                    <select id="cityDropDown" required
                            class="form-control"
                            ng-options="a.id as a.name + ' | '+ a.zipCode for a in vm.cities"
                            ng-model="vm.property.address.cityId"
                            ui-jq="selectpicker"
                            ui-options='{ iconBase: "famfamfam-flag", tickIcon: "fa fa-check" }'
                            ng-change="vm.changedCity(vm.property.address.cityId)"
                            data-live-search="true" title="@L("PfSelectCity")">
                        <option value=""></option>
                    </select>
                </div>
            </div>

C#

public async Task<ListResultOutput<CityListDto>> GetAllCitiesAsync()
        {
            var cities = await _cityRepository
                .GetAllListAsync();

            return new ListResultOutput<CityListDto>(cities.OrderBy(o => o.Name).MapTo<List<CityListDto>>());
        }

4 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    If you are making a seperate AJAX call for eash request, you may consider to unify it. I generally suggest to lazy load cache. But if the first customer must not be waited, you can cache it in PostInitialize event of your module.

  • User Avatar
    0
    sampath created

    Hi, Thanks for the feedback.But I didn't get what you said exactly.Could you give more info about that ? Thanks.

    If you are making a separate AJAX call for each request, you may consider to unify it. I generally suggest to lazy load cache. : Yes,Now I have separate AJAX requests for each and every drop down.So could you explain it little bit about unify and lazy load cache here ?

    if the first customer must not be waited, you can cache it in PostInitialize event of your module. : At this moment I have used loader animation until all the ajax calls are done.So can you explain what is this " cache it in PostInitialize event of your module" ? If you can show me a simple example,I'll highly appreciate it.Thanks.

    <div busy-if="vm.loadingProperties></div>
    
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    I'm not sure we are talking about same caching. I thought server-side caching (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching">http://www.aspnetboilerplate.com/Pages/ ... ts/Caching</a>). But you may thought client-side caching (it can be effective for SPA).

    For server side caching, first you should understand it well: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching">http://www.aspnetboilerplate.com/Pages/ ... ts/Caching</a> When you first request an item from cache, it's retrieved from database. Then you will get from cache for next requests (if you don't request for a while, it's removed from cache). I think you already know that. So, if you make the first request in PreInitialize of your module, then first requester use does not wait at all (no db operation).

    To unify 2 ajax call, create an app service method that returns a class contains all data of these 2 requests. So, you will make single ajax call.

  • User Avatar
    0
    sampath created

    Hi, Yes,me too talk about the server side caching.Thanks for the feedback.I got your point :)