title: Redis data type and commands to create a shopping cart
body: <p>I've been using <code>redis</code> with <code>laravel</code> for a while now to do simple things like caching data returned from my <code>lumen</code> API but very curious to learn more.</p>
  
  <p>My goal is to implement a shopping cart I already have on <code>mysql</code> in <code>redis</code> and want some advice as to what redis <code>data types</code> and <code>commands</code> I can use to achieve this.</p>
  
  <p>At the moment I'm using a <code>mysql</code> DB with <code>laravel</code> <code>eloquent</code> to handle my cart operations.</p>
  
  <ol>
  <li>Create a Cart</li>
  <li>Add Items</li>
  <li>Remove Items</li>
  <li>Increase Item Qty</li>
  <li>Decrease Item Qty</li>
  </ol>
  
  <p>I identify each <code>cart</code> by either <code>user_id</code> if the customer is signed in, <code>session_id</code> if customer not signed in or both.</p>
  
  <p>Long story short this is my current setup</p>
  
  <p><a href="https://i.stack.imgur.com/rWDNW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rWDNW.jpg" alt="DB SETUP"></a></p>
  
  <p>The <code>table</code> relationships are as below;</p>
  
  <ol>
  <li>Cart hasMany CartItems</li>
  <li>Cart hasMany CartModifierItems</li>
  <li>CartItems belongsTo Cart</li>
  <li>CartModifierItems belongsTo Cart</li>
  <li>CartModifierItems belongsTo CartItems</li>
  </ol>
  
  <p>I'm using <code>laravel</code> and <code>lumen</code> for my backend and <code>angularJS</code> for my frontend.. all actions are sent via <code>$http</code>.</p>
  
  <p>I've read through all the <code>redis</code> <code>data types</code> but still not clear which would be best to replicate the system I have in <code>mysql</code></p>
  
  <p>Any advice/guidance/code snippets appreciated.</p>