咏南中间件开始支持redis client接口调用

咏南中间件开始支持redis client接口调用

咏南中间件封装了redis client接口,可以支持REDIS了。

如下图,将数据集写入REDIS缓存,和从REDIS缓存获取数据:

procedure TForm2.Button1Click(Sender: TObject);
var
  lData: TRedisString;
  lCacheKey: string;
  lStream: TStringStream;
begin
  lCacheKey := 'goods';
  lStream := TStringStream.Create;
  try
    lData := FRedis.GET(lCacheKey);
    if lData.HasValue then
    begin
      lStream.WriteString(lData);
      lStream.Position := 0;
      FDQuery1.LoadFromStream(lStream, sfJSON);
    end
    else
    begin
      FDQuery1.Open('SELECT * FROM tgoods');
      FDQuery1.SaveToStream(lStream, sfJSON);
      lStream.Position := 0;
      FRedis.&SET(lCacheKey, lStream.DataString, 30);
    end;
  finally
    lStream.Free;
  end;
end;

  

posted @ 2019-03-03 10:51  delphi中间件  阅读(882)  评论(0编辑  收藏  举报