Mark
Mark

Reputation: 2203

ServiceStack - Autoquery & OrmLiteCacheClient

ServiceStack comes with some great features including AutoQuery and the most recent update includes a great Admin UI.

I am hoping to achieve the following, use OrmLiteCacheClient as the database for AutoQuery.

More specifically,

  1. I am looking to cache(/store) a number of objects (Response DTOs) to OrmLiteCacheClient

  2. Use AutoQuery for taking care of request and response of those entities saved to the OrmLiteCacheClient

Is this achievable?

Upvotes: 1

Views: 124

Answers (1)

mythz
mythz

Reputation: 143319

I am hoping to achieve the following, use OrmLiteCacheClient as the database for AutoQuery.

No that's not possible, AutoQuery works by constructing an SQL expression from an AutoQuery Request which gets executed by a remote RDBMS, the results of which are used to populate the AutoQuery Response DTO.

But you can still Cache an AutoQuery Service like any other Service, e.g:

public class TechnologyServices : Service
{
    public IAutoQuery AutoQuery { get; set; }

    //Cached AutoQuery
    public object Any(FindTechnologies query)
    {
        var key = Request.QueryString.ToString();
        return Request.ToOptimizedResultUsingCache(Cache, key, () =>
        {
            var q = AutoQuery.CreateQuery(query, Request);
            return AutoQuery.Execute(query, q);
        });
    }
}

Upvotes: 2

Related Questions