UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'alaWXVDWFvXf8O7JStqSirOCKzsi/56uIBztYPo4sBo=' 
WHERE 
  key_id = 'b8820f82dbf284125a46a6bf65575773a4faff94ff33e8d297e715c2cc225c47' 
  AND (
    token = 'alaWXVDWFvXf8O7JStqSirOCKzsi/56uIBztYPo4sBo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037