UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'bqugGF8o65tVa4zUP7iEWYYzxoJqgx+GQX3YOj8mYyc=' 
WHERE 
  key_id = '1d742360e58c44afd5887508086cb7a9257bad32b569c7fcf92b983fd01f82b9' 
  AND (
    token = 'bqugGF8o65tVa4zUP7iEWYYzxoJqgx+GQX3YOj8mYyc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00050