UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'a7T+owbAlJvSRZQqqms8QXqkKeBB71C/d1joA161pCY=' 
WHERE 
  key_id = 'c403cbcf807510ffe652c41b2150edaae42a8875553060b48482e262d015101b' 
  AND (
    token = 'a7T+owbAlJvSRZQqqms8QXqkKeBB71C/d1joA161pCY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00046