UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '3mS5S1mLyMVS58U5AycWZLvRRHZ8ijY+OPvRvw/Dedg=' 
WHERE 
  key_id = 'b77b981f809618f105b1cf10fe35626a30684d8b28eea3962a8065af68c95c8a' 
  AND (
    token = '3mS5S1mLyMVS58U5AycWZLvRRHZ8ijY+OPvRvw/Dedg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041