UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'QY521dturO6vI55qr+ReChEyo3K3vLBBQBBwDklLAok=' 
WHERE 
  key_id = '84c78e189d3131b563e841720efc34a6338b660b0966e0d4d5be5b3096f25412' 
  AND (
    token = 'QY521dturO6vI55qr+ReChEyo3K3vLBBQBBwDklLAok=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026