UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Jh8j9wzsK5OS2q43mLQkfzBMIXakOZNN3bpETZoJ0Zk=' 
WHERE 
  key_id = '583146221933c8d253a28e60d88a64b6372d90ff93086cc5766f1102e596cfc2' 
  AND (
    token = 'Jh8j9wzsK5OS2q43mLQkfzBMIXakOZNN3bpETZoJ0Zk=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030