Announcement

Collapse
No announcement yet.

Redis!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Redis!

    I see that the newest Empresa release includes support for Redis. I've read about Redis, and I might like to do some experiments with it. Can you please provide, or give me links to, some more documentation on how to install it and how to call it from Miva Script code?

    (For those who aren't familiar with Redis, it's a "NOSQL" database. It does database-like things, but its structure is a lot different from the tables-and-queries approach that we're used to. I love working with SQL, but it's interesting and kind of refreshing to read about other approaches. Details can be found at https://redis.io/ .)

    Muchas gracias! --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    #2
    If you're using the 3x configuration you'll need to add
    Code:
    <SYSTEM-LIB CODE="hiredis" LIBRARY="/path/to/libhiredis.so
    to your mivavm.conf or if you are using the env configuration you'll need to set environment variable
    Code:
    MvCONFIG_SYSTEMLIB_HIREDIS
    with the path to the libhiredis.so.

    Then you can connect to redis with something like
    Code:
    <MvIF EXPR = "{ NOT redis_connect( "ip/hostname", "port", l.conn_id ) }">
         <MvEVAL EXPR = "{ redis_last_error() }">
         <MvEXIT>
    </MvIF>
    You can then use l.conn_id variable and pass it to all other functions. The l.conn_id variable allows you to connect to multiple instances of redis at once and perform independent operations on any instance.

    Let me know about any other questions you may have.
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      What is it being used for in Miva Merchant at the moment?
      M.A.D.* since 1997

      http://www.scotsscripts.com

      *miva application developers

      Comment


        #4
        Originally posted by Scot - ScotsScripts.com View Post
        What is it being used for in Miva Merchant at the moment?
        Nothing at the moment. No definitive plans to use it yet but we have ideas on what it could be used for. Caching baskets, pages, etc...
        David Carver
        Miva, Inc. | Software Developer

        Comment


          #5
          Yeah, it looks cool, super easy tracking of simple values. Do any stock miva config setups support redis or is it something we'll need to ask the host to add to the config file? Is there a way to test if it's ready to go without the trial and see if there's an error method?
          M.A.D.* since 1997

          http://www.scotsscripts.com

          *miva application developers

          Comment


            #6
            Right now, none of the hosting environments have Redis installed. You'd probably have to have an instance of Redis installed on your local computer, open up the firewall for the port, and then you could connect to it from your Miva site (or run everything locally). If you went that route you should also enable the Redis authentication so randoms on the internet couldn't connect to it. After you connected through redis_connect, you'd need to call redis_auth that way you could start calling all the other functions.
            David Carver
            Miva, Inc. | Software Developer

            Comment


              #7
              I am testing some redis ideas on AWS. I have a redis server setup. However, I am lost on locating libhiredis.so .... ideas? suggestions? Where to find it?
              William Gilligan - Orange Marmalade, Inc.
              www.OrangeMarmaladeinc.com

              Comment


                #8
                The client library is going to be platform specific and needs to be either built for the server in question, or installed from a software repository supported by the server in question if ongoing updates are desirable and the repository (and its maintainer) are trustworthy. If your test server is CentOS 7 for example, you could use the EPEL repository to install libhiredis and not worry about building it.
                David Hubbard
                CIO
                Miva
                [email protected]
                http://www.miva.com

                Comment


                  #9
                  Thanks! Took me awhile, but I finally got it figured out - I think...
                  William Gilligan - Orange Marmalade, Inc.
                  www.OrangeMarmaladeinc.com

                  Comment


                    #10
                    Ok - next question.... when trying to compile using the examples at mivascript.com I get:

                    CE_167: Function name 'redis_connect' not defined nor recognized as an external function.
                    CE_167: Function name 'redis_last_error' not defined nor recognized as an external function.
                    CE_167: Function name 'redis_incr' not defined nor recognized as an external function.
                    CE_167: Function name 'redis_get' not defined nor recognized as an external function.
                    CE_167: Function name 'redis_disconnect' not defined nor recognized as an external function.

                    Is there a newer mvc to handle this? I am running 5.32
                    William Gilligan - Orange Marmalade, Inc.
                    www.OrangeMarmaladeinc.com

                    Comment


                      #11
                      Originally posted by wmgilligan View Post
                      Ok - next question.... when trying to compile using the examples at mivascript.com I get:

                      CE_167: Function name 'redis_connect' not defined nor recognized as an external function.
                      CE_167: Function name 'redis_last_error' not defined nor recognized as an external function.
                      CE_167: Function name 'redis_incr' not defined nor recognized as an external function.
                      CE_167: Function name 'redis_get' not defined nor recognized as an external function.
                      CE_167: Function name 'redis_disconnect' not defined nor recognized as an external function.

                      Is there a newer mvc to handle this? I am running 5.32
                      Are you compiling on Windows? If so, we currently are not supporting Redis on Windows servers.
                      David Carver
                      Miva, Inc. | Software Developer

                      Comment


                        #12
                        easy answer - yes. Compiling on a mac with a windows partition.
                        But - the server is on linux. Do you really mean - "the complier does not support compiling redis functions on windows"?
                        William Gilligan - Orange Marmalade, Inc.
                        www.OrangeMarmaladeinc.com

                        Comment


                          #13
                          We do not ship the builtin redis.so shared object with the Windows compiler / VM. If you want to compile your test code you'll need to make sure you are using a UNIX-like system.
                          David Carver
                          Miva, Inc. | Software Developer

                          Comment


                            #14
                            Are their any updated install docs for complier on MAC OS Mojave? All I find is something from 2007..
                            William Gilligan - Orange Marmalade, Inc.
                            www.OrangeMarmaladeinc.com

                            Comment


                              #15
                              I'm not aware of any install docs for OSX. I downloaded the compiler from mivascript.com, extracted the download with
                              Code:
                              tar xf msc-v5.32-macosx_x64.tar.gz
                              and then moved the extracted folder to /usr/local/msc. Then add /usr/local/msc/bin to your PATH if it's not already part of it. Then you should be able to run
                              Code:
                              mvc my_redis_test.mv
                              to compile your code.
                              Miva Merchant Empresa. Installs on both Unix-based and Windows web servers, and enables them to run Miva Merchant and other MivaScript-based web applications.
                              David Carver
                              Miva, Inc. | Software Developer

                              Comment

                              Working...
                              X