咏南中间件开始支持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;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/10464296.html