module test_redis

  contains
  SUBROUTINE test()
    use RedisInterface
    use SimulationVariables
    use json_module
    character(len=:),allocatable::s2
    character(len=:),allocatable::redisContent
    type(json_value),pointer :: jsonvalue
    type(json_core) :: jsoncore

    call initConnection()
    print *,"redis exmaple program"

    call jsoncore%create_object(jsonvalue,'')
    call ConfigurationToJson(jsonvalue)
    call WarningsToJson(jsonvalue)
    call ProblemsToJson(jsonvalue)
    print *,"write starts"
    call jsoncore%serialize(jsonvalue,redisContent)
    ! s = "Test redis write!"
    call setData(redisContent)
    print *,"write ends len=",len(redisContent)

    call getData(s2)
    print *,"len(read)=",len(s2)
    print *, s2(1:10),' .... ', s2(len(s2)-10:len(s2))
    call deallocateData()
    ! print *,"S2 = ",s2
    deallocate(s2)
  end SUBROUTINE
end module test_redis

program redis_example
  use test_redis
  call test()
end program redis_example
